npm.io
1.0.0 • Published 7 years ago

@ngard/tiny-unique

Licence
MIT
Version
1.0.0
Deps
0
Size
12 kB
Vulns
0
Weekly
0

tiny-unique

source bundle size build status license

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.


lodash.uniq: bundle size
tiny-unique: bundle size


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]

Keywords