File tree Expand file tree Collapse file tree 2 files changed +5
-5
lines changed Expand file tree Collapse file tree 2 files changed +5
-5
lines changed Original file line number Diff line number Diff line change @@ -8,7 +8,7 @@ since: 12.1.0
8
8
9
9
Given an array of items -- and optionally, a function to determine their identity -- return a new array without any duplicates.
10
10
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 .
12
12
13
13
``` ts
14
14
import * as _ from ' radashi'
@@ -26,8 +26,8 @@ const fish = [
26
26
},
27
27
{
28
28
name: ' Salmon' ,
29
- weight: 22 ,
30
- source: ' river ' ,
29
+ weight: 23 ,
30
+ source: ' stream ' ,
31
31
},
32
32
]
33
33
Original file line number Diff line number Diff line change @@ -9,9 +9,9 @@ describe('unique', () => {
9
9
test ( 'uses key fn to correctly remove duplicate items' , ( ) => {
10
10
const list = [
11
11
{ id : 'a' , word : 'hello' } ,
12
- { id : 'a' , word : 'hello' } ,
13
- { id : 'b' , word : 'oh' } ,
12
+ { id : 'a' , word : 'goodbye' } ,
14
13
{ id : 'b' , word : 'oh' } ,
14
+ { id : 'b' , word : 'no' } ,
15
15
{ id : 'c' , word : 'yolo' } ,
16
16
]
17
17
const result = _ . unique ( list , x => x . id )
You can’t perform that action at this time.
0 commit comments