Skip to content

Commit 24b3406

Browse files
authored
chore(docs): correction that unique preserves the original order (#433)
1 parent 7d519d3 commit 24b3406

File tree

2 files changed

+5
-5
lines changed

2 files changed

+5
-5
lines changed

docs/array/unique.mdx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ since: 12.1.0
88

99
Given an array of items -- and optionally, a function to determine their identity -- return a new array without any duplicates.
1010

11-
The function does not preserve the original order of items.
11+
The function preserves the original order of items, keeping the first occurence and omitting duplicates.
1212

1313
```ts
1414
import * as _ from 'radashi'
@@ -26,8 +26,8 @@ const fish = [
2626
},
2727
{
2828
name: 'Salmon',
29-
weight: 22,
30-
source: 'river',
29+
weight: 23,
30+
source: 'stream',
3131
},
3232
]
3333

tests/array/unique.test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,9 @@ describe('unique', () => {
99
test('uses key fn to correctly remove duplicate items', () => {
1010
const list = [
1111
{ id: 'a', word: 'hello' },
12-
{ id: 'a', word: 'hello' },
13-
{ id: 'b', word: 'oh' },
12+
{ id: 'a', word: 'goodbye' },
1413
{ id: 'b', word: 'oh' },
14+
{ id: 'b', word: 'no' },
1515
{ id: 'c', word: 'yolo' },
1616
]
1717
const result = _.unique(list, x => x.id)

0 commit comments

Comments
 (0)