UNPKG

lakutata

Version:

An IoC-based universal application framework.

72 lines (67 loc) 1.71 kB
"use strict"; Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" }); function r(r) { if (typeof r !== "object" || r === null) { return false; } const t = Object.getPrototypeOf(r); return (t === null || t === Object.prototype || Object.getPrototypeOf(t) === null) && !(Symbol.toStringTag in r) && !(Symbol.iterator in r); } function t(t, e = {}) { if (!r(t) && !Array.isArray(t)) { throw new TypeError("Expected a plain object or array"); } const {deep: o, compare: n} = e; const s = []; const c = []; const i = t => { const e = s.indexOf(t); if (e !== -1) { return c[e]; } const o = []; s.push(t); c.push(o); o.push(...t.map((t => { if (Array.isArray(t)) { return i(t); } if (r(t)) { return u(t); } return t; }))); return o; }; const u = t => { const e = s.indexOf(t); if (e !== -1) { return c[e]; } const p = {}; const y = Object.keys(t).sort(n); s.push(t); c.push(p); for (const e of y) { const n = t[e]; let s; if (o && Array.isArray(n)) { s = i(n); } else { s = o && r(n) ? u(n) : n; } Object.defineProperty(p, e, { ...Object.getOwnPropertyDescriptor(t, e), value: s }); } return p; }; if (Array.isArray(t)) { return o ? i(t) : t.slice(); } return u(t); } exports.SortKeys = t;