test(uniqWith): Add test cases for uniqWith (#36)

* fix(uniqWith): Add test cases for uniqWith

* Update src/array/uniqWith.spec.ts

* Update src/array/uniqWith.spec.ts

---------

Co-authored-by: Sojin Park <raon0211@gmail.com>
This commit is contained in:
Bang, Jaehun 2024-06-13 10:40:52 +09:00 committed by GitHub
parent 79ce446a51
commit dd5699631c
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 4 additions and 1 deletions

View File

@ -12,5 +12,8 @@ describe('uniqWith', () => {
(a, b) => a.x === b.x
)
).toEqual([{ x: 1, y: 2 }]);
expect(uniqWith([1.2, 1.5, 2.1, 3.2, 5.7, 5.3, 7.19], (a, b) => Math.abs(a - b) < 1)).toEqual([
1.2, 3.2, 5.7, 7.19,
]);
});
});

View File

@ -10,7 +10,7 @@
* @example
* ```ts
* uniqWith([1.2, 1.5, 2.1, 3.2, 5.7, 5.3, 7.19], (a, b) => Math.abs(a - b) < 1);
* // [1, 2, 3, 5, 7]
* // [1.2, 3.2, 5.7, 7.19]
* ```
*/
export function uniqWith<T>(arr: T[], areItemsEqual: (item1: T, item2: T) => boolean): T[] {