dedupe
移除数组中重复的值
Study from seriousManual/dedupe
Installation
$ npm install dedupe
Usage
primitive types
var dedupe = var a = 1 2 2 3var b = console //result: [1, 2, 3]
complex types
Here the string representation of the object is used for comparism. The mechanism is similar to JSON.stringifing but a bit more efficient.
That means that {}
is considered egal to {}
.
var dedupe = var aa = a: 2 a: 1 a: 1 a: 1var bb = console //result: [{a: 2}, {a: 1}]
complex types types with custom hasher
var dedupe = var aaa = a: 2 b: 1 a: 1 b: 2 a: 1 b: 3 a: 1 b: 4var bbb = console //result: [{a: 2, b: 1}, {a: 1,b: 2}]