UNPKG

aims-js

Version:
2 lines (1 loc) 977 B
(function(o,u){typeof exports=="object"&&typeof module<"u"?module.exports=u():typeof define=="function"&&define.amd?define(u):(o=typeof globalThis<"u"?globalThis:o||self,o.aims=u())})(this,function(){"use strict";const o=(()=>{const f=(i,t,s)=>{const l=typeof s;if(s&&l==="object")if(Array.isArray(s))for(const e of s)t=f(i,t,e);else for(const e of Object.keys(s)){const n=s[e];typeof n=="function"?t[e]=n(t[e],r):n===void 0?i&&!isNaN(e)?t.splice(e,1):delete t[e]:n===null||typeof n!="object"||n.constructor!==Object||Array.isArray(n)?t[e]=n:typeof t[e]=="object"?t[e]=n===t[e]?n:r(t[e],n):t[e]=f(!1,{},n)}else l==="function"&&(t=s(t,r));return t},r=(i,...t)=>{const s=Array.isArray(i);return f(s,s?i.slice():Object.assign({},i),t)};return r})();return({a:f=o,i:r,m:i=[],s:t=!1}={},s)=>{let l=f({},r||{}),e;const n=a=>{l=f(l,a),s&&s(e)};e=Object.assign({get:()=>l},!t&&{patch:n});const b=[i].flat().map(a=>a(e,!!t&&n));return Object.assign(e,...b),s&&s(e),Object.freeze(e)}});