Codacy issue fixes

This commit is contained in:
Angelos Chalaris
2018-08-02 12:02:29 +03:00
parent 205424cf03
commit 45de1d6377
5 changed files with 8 additions and 8 deletions

View File

@ -7,7 +7,7 @@ The comparator function takes four arguments: the values of the two elements bei
```js ```js
const filterNonUniqueBy = (arr, fn) => const filterNonUniqueBy = (arr, fn) =>
arr.filter((v, i) => arr.every((x, j) => (i == j) == fn(v, x, i, j))); arr.filter((v, i) => arr.every((x, j) => (i === j) === fn(v, x, i, j)));
``` ```
```js ```js

View File

@ -1,3 +1,3 @@
const filterNonUniqueBy = (arr, fn) => const filterNonUniqueBy = (arr, fn) =>
arr.filter((v, i) => arr.every((x, j) => (i == j) == fn(v, x, i, j))); arr.filter((v, i) => arr.every((x, j) => (i === j) === fn(v, x, i, j)));
module.exports = filterNonUniqueBy; module.exports = filterNonUniqueBy;

View File

@ -14,7 +14,7 @@ test('filterNonUniqueBy works for properties', () => {
{ id: 1, value: 'd' }, { id: 1, value: 'd' },
{ id: 0, value: 'e' }, { id: 0, value: 'e' },
], ],
(a, b) => a.id == b.id (a, b) => a.id === b.id
)).toEqual([ { id: 2, value: 'c' } ]); )).toEqual([ { id: 2, value: 'c' } ]);
}); });
@ -27,6 +27,6 @@ test('filterNonUniqueBy works for nested properties', () => {
{ id: 1, value: 'd', n: {p: 0} }, { id: 1, value: 'd', n: {p: 0} },
{ id: 0, value: 'e', n: {p: 1} }, { id: 0, value: 'e', n: {p: 1} },
], ],
(a, b) => a.id == b.id (a, b) => a.id === b.id
)).toEqual([ { id: 2, value: 'c', n: {p: 2} } ]); )).toEqual([ { id: 2, value: 'c', n: {p: 2} } ]);
}); });

View File

@ -14,7 +14,7 @@ test('uniqueElementsBy works for properties', () => {
{ id: 1, value: 'd' }, { id: 1, value: 'd' },
{ id: 0, value: 'e' }, { id: 0, value: 'e' },
], ],
(a, b) => a.id == b.id (a, b) => a.id === b.id
)).toEqual([ { id: 0, value: 'a' }, { id: 1, value: 'b' }, { id: 2, value: 'c' } ]); )).toEqual([ { id: 0, value: 'a' }, { id: 1, value: 'b' }, { id: 2, value: 'c' } ]);
}); });
@ -27,6 +27,6 @@ test('uniqueElementsBy works for nested properties', () => {
{ id: 1, value: 'd', n: {p: 0} }, { id: 1, value: 'd', n: {p: 0} },
{ id: 0, value: 'e', n: {p: 1} }, { id: 0, value: 'e', n: {p: 1} },
], ],
(a, b) => a.id == b.id (a, b) => a.id === b.id
)).toEqual([ { id: 0, value: 'a', n: {p: 0} }, { id: 1, value: 'b', n: {p: 1} }, { id: 2, value: 'c', n: {p: 2} } ]); )).toEqual([ { id: 0, value: 'a', n: {p: 0} }, { id: 1, value: 'b', n: {p: 1} }, { id: 2, value: 'c', n: {p: 2} } ]);
}); });

View File

@ -14,7 +14,7 @@ test('uniqueElementsByRight works for properties', () => {
{ id: 1, value: 'd' }, { id: 1, value: 'd' },
{ id: 0, value: 'e' }, { id: 0, value: 'e' },
], ],
(a, b) => a.id == b.id (a, b) => a.id === b.id
)).toEqual([ { id: 0, value: 'e' }, { id: 1, value: 'd' }, { id: 2, value: 'c' } ]); )).toEqual([ { id: 0, value: 'e' }, { id: 1, value: 'd' }, { id: 2, value: 'c' } ]);
}); });
@ -27,6 +27,6 @@ test('uniqueElementsByRight works for nested properties', () => {
{ id: 1, value: 'd', n: {p: 0} }, { id: 1, value: 'd', n: {p: 0} },
{ id: 0, value: 'e', n: {p: 1} }, { id: 0, value: 'e', n: {p: 1} },
], ],
(a, b) => a.id == b.id (a, b) => a.id === b.id
)).toEqual([ { id: 0, value: 'e', n: {p: 1} }, { id: 1, value: 'd', n: {p: 0} }, { id: 2, value: 'c', n: {p: 2} } ]); )).toEqual([ { id: 0, value: 'e', n: {p: 1} }, { id: 1, value: 'd', n: {p: 0} }, { id: 2, value: 'c', n: {p: 2} } ]);
}); });