UNPKG

ts-prime

Version:

A utility library for JavaScript and Typescript.

32 lines (31 loc) 1.06 kB
var __spreadArrays = (this && this.__spreadArrays) || function () { for (var s = 0, i = 0, il = arguments.length; i < il; i++) s += arguments[i].length; for (var r = Array(s), k = 0, i = 0; i < il; i++) for (var a = arguments[i], j = 0, jl = a.length; j < jl; j++, k++) r[k] = a[j]; return r; }; import { purry } from './purry'; import { uniq } from './uniq'; import { deepEqual } from './deepEqual'; function _deepUniq(array, mode) { var uniqArr = uniq(array); var uniqeItems = []; var compareList = __spreadArrays(uniqArr); while (compareList.length !== 0) { var compareValue = compareList.shift(); if (!compareValue) break; for (var iIndex in compareList) { if (deepEqual(compareValue, compareList[iIndex], mode)) { compareList.splice(parseInt(iIndex), 1); continue; } } uniqeItems.push(compareValue); } return uniqeItems; } export function deepUniq() { return purry(_deepUniq, arguments); }