Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

nub

Package Overview
Dependencies
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

nub

Uniqueness functions

  • 1.0.0
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
100K
decreased by-55.87%
Maintainers
1
Weekly downloads
 
Created
Source

nub

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.

example

$ 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 ]

methods

var nub = require('nub')

nub(xs)

Return a new array with all the uniqe elements in xs.

Uniqueness is calculated === style so the types matter.

nub.by(xs, cmp)

Use cmp(x,y) function to compare elements instead of the default. cmp should return whether the two elements are equal as a boolean.

install

With npm do:

npm install nub

To use nub in the browser, use browserify or fetch a UMD build from browserify CDN.

license

MIT

Keywords

FAQs

Package last updated on 12 Sep 2014

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc