@ngard/tiny-unique
v1.0.0
Published
A minimal-weight deduplicating utility similar to lodash.uniq
Downloads
5
Readme
tiny-unique
A minimal utility similar to lodash.uniq
. For when every byte counts!
Returns a copy of the passed array with only the first of any duplicate values included.
Syntax
unique(/* array [, comparator] */);
Parameters
array
- An array of possibly duplicated values
comparator
- An optional function that compares two values for equality. Defaults to ===
.
Returns
An array containing only the first occurrence of each value in the passed array, in the order that they occur.
Use
import { unique } from '@ngard/tiny-unique';
const set = unique([1, true, 'foo', 3, 1, true]);
// set is [1, true, 'foo', 3]