"use strict"; var __importDefault = (this && this.__importDefault) || function (mod) { return (mod && mod.__esModule) ? mod : { "default": mod }; }; Object.defineProperty(exports, "__esModule", { value: true }); exports.default = uniqueByKey; const slugify_1 = __importDefault(require("./slugify")); function uniqueByKey(arr, key) { let newArray = []; let uniqueValues = []; for (let i = 0; i < arr.length; i++) { const item = arr[i]; let targetValue; if (Array.isArray(key)) { const targetVals = []; for (let k = 0; k < key.length; k++) { const ky = key[k]; const targetValuek = (0, slugify_1.default)(String(item[ky])); targetVals.push(targetValuek); } targetValue = (0, slugify_1.default)(targetVals.join(",")); } else { targetValue = (0, slugify_1.default)(String(item[key])); } if (!targetValue) continue; if (uniqueValues.includes(targetValue)) continue; newArray.push(item); uniqueValues.push(targetValue); } return newArray; }