mirror of
https://github.com/toss/es-toolkit.git
synced 2024-11-27 14:57:44 +03:00
docs(uniqBy): fix docs for uniqBy
(#231)
* docs: fix uniqBy doc example * test: add test case --------- Co-authored-by: Sojin Park <raon0211@toss.im>
This commit is contained in:
parent
553f136c94
commit
404d4a51a8
@ -21,5 +21,5 @@ function uniqBy<T, U>(arr: T[], mapper: (item: T) => U): T[];
|
||||
|
||||
```typescript
|
||||
uniqBy([1.2, 1.5, 2.1, 3.2, 5.7, 5.3, 7.19], Math.floor);
|
||||
// [1.2, 2.1, 3.3, 5.7, 7.19]
|
||||
// [1.2, 2.1, 3.2, 5.7, 7.19]
|
||||
```
|
||||
|
@ -21,5 +21,5 @@ function uniqBy<T, U>(arr: T[], mapper: (item: T) => U): T[];
|
||||
|
||||
```typescript
|
||||
uniqBy([1.2, 1.5, 2.1, 3.2, 5.7, 5.3, 7.19], Math.floor);
|
||||
// [1.2, 2.1, 3.3, 5.7, 7.19]
|
||||
// [1.2, 2.1, 3.2, 5.7, 7.19]
|
||||
```
|
||||
|
@ -4,5 +4,6 @@ import { uniqBy } from './uniqBy';
|
||||
describe('uniqBy', () => {
|
||||
it('should work with a `mapper`', () => {
|
||||
expect(uniqBy([2.1, 1.2, 2.3], Math.floor)).toEqual([2.1, 1.2]);
|
||||
expect(uniqBy([1.2, 1.5, 2.1, 3.2, 5.7, 5.3, 7.19], Math.floor)).toEqual([1.2, 2.1, 3.2, 5.7, 7.19]);
|
||||
});
|
||||
});
|
||||
|
@ -11,7 +11,7 @@
|
||||
* @example
|
||||
* ```ts
|
||||
* uniqBy([1.2, 1.5, 2.1, 3.2, 5.7, 5.3, 7.19], Math.floor);
|
||||
* // [1.2, 2.1, 3.3, 5.7, 7.19]
|
||||
* // [1.2, 2.1, 3.2, 5.7, 7.19]
|
||||
* ```
|
||||
*/
|
||||
export function uniqBy<T, U>(arr: readonly T[], mapper: (item: T) => U): T[] {
|
||||
|
Loading…
Reference in New Issue
Block a user