UNPKG

aims-js

Version:
42 lines (41 loc) 1.14 kB
const u = (() => { const r = (n, t, s) => { const l = typeof s; if (s && l === "object") if (Array.isArray(s)) for (const e of s) t = r(n, t, e); else for (const e of Object.keys(s)) { const f = s[e]; typeof f == "function" ? t[e] = f(t[e], i) : f === void 0 ? n && !isNaN(e) ? t.splice(e, 1) : delete t[e] : f === null || typeof f != "object" || f.constructor !== Object || Array.isArray(f) ? t[e] = f : typeof t[e] == "object" ? t[e] = f === t[e] ? f : i(t[e], f) : t[e] = r(!1, {}, f); } else l === "function" && (t = s(t, i)); return t; }, i = (n, ...t) => { const s = Array.isArray(n); return r( s, s ? n.slice() : Object.assign({}, n), t ); }; return i; })(), b = ({ a: r = u, i, m: n = [], s: t = !1 } = {}, s) => { let l = r({}, i || {}), e; const f = (a) => { l = r(l, a), s && s(e); }; e = Object.assign({ get: () => l }, !t && { patch: f }); const o = [n].flat().map((a) => a(e, !!t && f)); return Object.assign(e, ...o), s && s(e), Object.freeze(e); }; export { b as default };