1.0.0 • Published 5 years ago

@ngard/tiny-unique v1.0.0

Weekly downloads
1
License
MIT
Repository
github
Last release
5 years ago

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]