UNPKG

ts-prime

Version:

A utility library for JavaScript and Typescript.

35 lines (34 loc) 1.19 kB
"use strict"; 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; }; Object.defineProperty(exports, "__esModule", { value: true }); var purry_1 = require("./purry"); var uniq_1 = require("./uniq"); var deepEqual_1 = require("./deepEqual"); function _deepUniq(array, mode) { var uniqArr = uniq_1.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_1.deepEqual(compareValue, compareList[iIndex], mode)) { compareList.splice(parseInt(iIndex), 1); continue; } } uniqeItems.push(compareValue); } return uniqeItems; } function deepUniq() { return purry_1.purry(_deepUniq, arguments); } exports.deepUniq = deepUniq;