Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Returns a array with only unique values. Otherwise known as a Set
JavaScript
branch: master

Fetching latest commit…

Cannot retrieve the latest commit at this time

Failed to load latest commit information.
.gitignore
LICENSE
README.md
index.js
package.json
test.js

README.md

uniqueify

Returns a array with only unique values. Otherwise known as a Set

browser support

npm install uniqueify

var uniqueify = require('uniqueify');

uniqueify(array);

// Example

test("The values returned should be unique", function(t) { t.plan(1);

var common_obj = {name: 'michael'};

var result = uniqueify([1,2,2,3,3,4,5,common_obj,6,common_obj, 7,{name: 'michael'}, [1,2,3], 8, [1,2,3], 9, [1,2,3,'random']]);

t.same(result, [1,2,3,4,5,6,7,8,9,{name:'michael'}, [1,2,3], [1,2,3,'random']]); });

** Note, objects are compared using deep equals. There is a bit of a performance hit when using objects and arrays but not much algorithmically at least.

Objects are maintained in a seperate list and that list is iterated over to compare, it is then added at the end. So all objects appear at the end of the resulting Set.

Something went wrong with that request. Please try again.