开发者社区> 镜像站> NPM> unique-concat
unique-concat
Concatenates two arrays, removing duplicates in the process and returns one array with unique values.
Last updated 7 years ago by thlorenz .
MIT · Repository · Bugs · Original npm · Tarball · package.json
$ cnpm install unique-concat 
SYNC missed versions from official npm registry.

unique-concat build status

testling badge

Concatenates two arrays, removing duplicates in the process and returns one array with unique values.

var concat = require('unique-concat');
var res = concat([ 1, 2, 3 ], [ 1, 2, 3, 4, 5, 6])
console.log(res);
// => [1, 2, 3, 4, 5, 6]

Installation

npm install unique-concat

Note

Works only with types that can be properly hashed, which means that they need to have a sensible .toString() implementation

Types that work as expected: int, string

Types that work with caveats: float (if one float is part of the array, all numbers are converted to string)

Types that don't work: object since obj.toString === '[ object ]' for all objects.

For more information see tests

License

MIT

Current Tags

  • 0.2.2                                ...           latest (7 years ago)

7 Versions

  • 0.2.2                                ...           7 years ago
  • 0.2.1                                ...           7 years ago
  • 0.2.0                                ...           7 years ago
  • 0.1.3                                ...           7 years ago
  • 0.1.2                                ...           7 years ago
  • 0.1.1                                ...           7 years ago
  • 0.1.0                                ...           7 years ago