package
Uniqueness functions
npm install nubGitHub-flavored package documentation.
Across all versions.
Download trend unavailable.
Runtime metadata.
Tagged topics.
Return all the unique elements of an array. You can specify your own uniqueness
comparison function with nub.by too.
These work like haskell's
nub
and
nubBy
functions in
Data.List.
$ node
> var nub = require('nub')
> nub([1,2,2,3,1,3])
[ 1, 2, 3 ]
> nub.by([ 2, 3, 5, 7, 8 ], function (x,y) { return x + y === 10 })
[ 2, 3, 5 ]var nub = require('nub')Return a new array with all the uniqe elements in xs.
Uniqueness is calculated === style so the types matter.
Use cmp(x,y) function to compare elements instead of the default.
cmp should return whether the two elements are equal as a boolean.
With npm do:
npm install nubTo use nub in the browser, use browserify or fetch a UMD build from browserify CDN.
MIT