JSPM

unique-array

1.0.1
  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 43
  • Score
    100M100P100Q54067F
  • License ISC

Removed duplicate elements from the array

Package Exports

  • unique-array

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 (unique-array) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

unique-array

Removed duplicate elements from the array using Set

Examples

var unique = require('unique-array');

unique([1, 1, 2, 3, 4]);
//=> [1, 2, 3, 4]

unique(['a', 'b', 'github', 'a', 'github']);
//=> ['a', 'b', 'github']

When removing duplicates, the position of the first occurrence of each value will be retained. For example,

unique([1, 2, 3, 4, 4, 5, 1, 6])
//=> [1, 2, 3, 4, 5, 6]

Usage

require('unique-array')( array )

Return unique elements of an input array.

Arguments:

  • array: A javascript array with elements to be unique'd.

Returns: A reference to a new array containing the unique elements. Elements are in the order of the first occurrence in the input array.

License

© 2016 vikram. MIT License