New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details →
Socket
Book a DemoSign in
Socket

make-unique

Package Overview
Dependencies
Maintainers
1
Versions
5
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

make-unique

Creates and makes an array without duplicates. Even with array of objects with a specified matcher.

latest
Source
npmnpm
Version
1.0.4
Version published
Weekly downloads
1.9K
54.7%
Maintainers
1
Weekly downloads
 
Created
Source

Build Status

make-unique

Creates and makes an array without duplicates. Even with array of objects with a specified matcher.

If no matcher specified, it will use Set if Set is available in V8.

Install

$ npm install make-unique --save

Usage

let unique = require('make-unique')

unique([1, 2, 3, 1]) // [1, 2, 3]

unique(array, matcher)

  • array Array the input array
  • matcher function(a, b) if matcher returns true, then it will treat a equals to b.

Cleans an array of objects with a specified filter to tell unique how to determine if two items are the 'same'

unique([
  {a: 1},
  {a: 2},
  {a: 1}

], (a, b) => {
  // if `a` and `b` contain the same `.a`, they are the 'same'
  return a.a === b.a
})
// [
//   {a: 1},
//   {a: 2}
// ]

License

MIT

Keywords

make-unique

FAQs

Package last updated on 12 Jul 2016

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