What is array-unique?
The array-unique npm package is a small utility that removes duplicate values from an array. It is useful when you need to ensure that an array contains only unique items without having to write custom deduplication logic.
What are array-unique's main functionalities?
Deduplicate an array
This feature allows you to remove duplicate values from an array, resulting in an array of only unique items. The `arrayUnique` function is used as a callback for the `filter` method.
[1, 2, 2, 3, 4, 4, 5, 5].filter(arrayUnique)
Other packages similar to array-unique
lodash.uniq
Lodash is a popular utility library that includes a `uniq` function. This function is similar to array-unique in that it removes duplicate values from an array. Lodash offers a wide range of additional utility functions, which makes it a more comprehensive solution than array-unique, but also larger in size.
underscore
Underscore.js is another utility library that provides a `uniq` function, similar to array-unique. It is comparable to Lodash in functionality and size, and it also offers a wide range of utility functions beyond array deduplication.
ramda
Ramda is a functional programming library that includes a `uniq` function. It is designed with a focus on functional programming patterns and immutability. Ramda's `uniq` function provides similar functionality to array-unique, but within the context of a larger functional programming toolkit.
array-unique
Remove duplicate values from an array. Fastest ES5 implementation.
Install
Install with npm:
$ npm install --save array-unique
Usage
var unique = require('array-unique');
var arr = ['a', 'b', 'c', 'c'];
console.log(unique(arr))
console.log(arr)
var unique = require("array-unique").immutable;
var arr = ['a', 'b', 'c', 'c'];
console.log(unique(arr))
console.log(arr)
About
Related projects
- arr-diff: Returns an array with only the unique values from the first array, by excluding all… more | homepage
- arr-flatten: Recursively flatten an array or arrays. This is the fastest implementation of array flatten. | homepage
- arr-map: Faster, node.js focused alternative to JavaScript's native array map. | homepage
- arr-pluck: Retrieves the value of a specified property from all elements in the collection. | homepage
- arr-reduce: Fast array reduce that also loops over sparse elements. | homepage
- arr-union: Combines a list of arrays, returning a single array with unique values, using strict equality… more | homepage
Contributing
Pull requests and stars are always welcome. For bugs and feature requests, please create an issue.
Building docs
(This document was generated by verb-generate-readme (a verb generator), please don't edit the readme directly. Any changes to the readme must be made in .verb.md.)
To generate the readme and API documentation with verb:
$ npm install -g verb verb-generate-readme && verb
Running tests
Install dev dependencies:
$ npm install -d && npm test
Author
Jon Schlinkert
License
Copyright © 2016, Jon Schlinkert.
Released under the MIT license.
This file was generated by verb-generate-readme, v0.1.28, on July 31, 2016.