@extra-array/unique.min

Removes duplicate values.

Downloads in past

Stats

StarsIssuesVersionUpdatedCreatedSize
@extra-array/unique.min
1402.10.198 months ago3 years agoMinified + gzip package size for @extra-array/unique.min in KB

Readme

Removes duplicate values. :package: :smileycat: :running: :vhs: :moon: :scroll: :newspaper: :bluebook:
Alternatives: unique, isUnique.

This is part of package extra-array.

This is browserified, minified version of @extra-array/unique.
It is exported as global variable arrayunique.
CDN: unpkg
, jsDelivr.



array.unique(x, [fc], [fm]);
// x:  an array
// fc: compare function (a, b)
// fm: map function (v, i, x)
:stopwatch: Compare function => O(n²).

const array = require("extra-array");

var x = [1, 2, 3, 4, 2, 3];
array.unique(x);
// [ 1, 2, 3, 4 ]

var x = [1, 2, 3, 4, -2, -3];
array.unique(x, (a, b) => Math.abs(a) - Math.abs(b));
// [ 1, 2, 3, 4 ]

array.unique(x, null, v => Math.abs(v));
// [ 1, 2, 3, 4 ]



References