UNPKG

typedash

Version:

modern, type-safe collection of utility functions

20 lines (18 loc) 494 B
'use strict'; // src/functions/unique/unique.ts function unique(iterable, comparator = defaultComparator) { if (comparator === defaultComparator) { return [...new Set(iterable)]; } const result = []; for (const value of iterable ?? []) { if (!result.some((other) => comparator(value, other))) { result.push(value); } } return result; } var defaultComparator = Object.is; exports.unique = unique; //# sourceMappingURL=out.js.map //# sourceMappingURL=index.cjs.map