JSPM

  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 1418
  • Score
    100M100P100Q144842F
  • License MIT

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

Package Exports

  • make-unique

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (make-unique) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

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