1.0.0 • Published 4 years ago

uniq-obj v1.0.0

Weekly downloads
-
License
MIT
Repository
-
Last release
4 years ago

uniq-obj

Create an array of unique objects.

const uniqobj = require('uniq-obj)

//no param
uniqObj([1, 2, 2, 3, 1, 2, 4])
// [1, 2, 3, 4]
uniqObj(['a', 'a', 'b', 'a', 'c', 'a', 'd']
// ['a', 'b', 'c', 'd']

// with property name
uniqObj([{a: 1}, {a: 1, b: 2}, {b: 2}], 'a')
// [{a: 1}, {b: 2}]
uniqObj([{a: 1}, {a: 1, b: 2}, {b: 2}], 'b')
// [{a: 1}, {a: 1, b: 2}]
})
// with properties
uniqObj([{a: 1, b: 2, c: 1}, {a: 1, b: 2}, {b: 2}], ['a', 'b'])
// [{a: 1, b: 2, c: 1}, {b: 2}]
})
// with function
uniqObj([{a: 1, b: 2, c: 1}, {a: 1, b: 2}, {b: 2}], 
        (a, b) => a.a === b.a || a.b === b.b)
// [{a: 1, b: 2, c: 1}]
})
1.0.0

4 years ago