Skip to content

Commit

Permalink
fix(uniqWith): Add test cases for uniqWith
Browse files Browse the repository at this point in the history
  • Loading branch information
jaehunn committed Jun 12, 2024
1 parent 79ce446 commit bb6f125
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
6 changes: 6 additions & 0 deletions src/array/uniqWith.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,10 @@ describe('uniqWith', () => {
)
).toEqual([{ x: 1, y: 2 }]);
});

it('should remove numbers that are within 1 unit of each other', () => {
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,
]);
});
});
2 changes: 1 addition & 1 deletion src/array/uniqWith.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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[] {
Expand Down

0 comments on commit bb6f125

Please sign in to comment.