Travis build: 110
This commit is contained in:
@ -7,21 +7,21 @@ The comparator function takes two arguments: the values of the two elements bein
|
||||
|
||||
```js
|
||||
const uniqueElementsByRight = (arr, fn) =>
|
||||
arr.reduceRight((acc, v) => {
|
||||
if (!acc.some(x => fn(v, x))) acc.push(v);
|
||||
return acc;
|
||||
}, []);
|
||||
arr.reduceRight((acc, v) => {
|
||||
if (!acc.some(x => fn(v, x))) acc.push(v);
|
||||
return acc;
|
||||
}, []);
|
||||
```
|
||||
|
||||
```js
|
||||
uniqueElementsByRight(
|
||||
[
|
||||
{ id: 0, value: 'a' },
|
||||
{ id: 1, value: 'b' },
|
||||
{ id: 2, value: 'c' },
|
||||
{ id: 1, value: 'd' },
|
||||
{ id: 0, value: 'e' },
|
||||
],
|
||||
(a, b) => a.id == b.id
|
||||
[
|
||||
{ id: 0, value: 'a' },
|
||||
{ id: 1, value: 'b' },
|
||||
{ id: 2, value: 'c' },
|
||||
{ id: 1, value: 'd' },
|
||||
{ id: 0, value: 'e' }
|
||||
],
|
||||
(a, b) => a.id == b.id
|
||||
); // [ { id: 0, value: 'e' }, { id: 1, value: 'd' }, { id: 2, value: 'c' } ]
|
||||
```
|
||||
|
||||
Reference in New Issue
Block a user