UNPKG

rubico

Version:

[a]synchronous functional programming

9 lines (7 loc) 1.48 kB
/** * rubico v2.6.2 * https://github.com/a-synchronous/rubico * (c) 2019-2024 Richard Tong * rubico may be freely distributed under the MIT license. */ !function(n,t){"object"==typeof module?module.exports=t:"function"==typeof define?define((()=>t)):n.pick=t}("object"==typeof globalThis?globalThis:this,function(){"use strict";const n=Array.isArray,t=/[.|[|\]]+/,e=function(n,t){const e=new Map,r=function(r){if(e.has(r))return e.get(r);const o=n(r);return e.set(r,o),e.size>t&&e.clear(),o};return r.cache=e,r}((function(n){const e=n.length-1,r="["==n[0],o="]"==n[e];return r&&o?n.slice(1,e).split(t):r?n.slice(1).split(t):o?n.slice(0,e).split(t):n.split(t)}),500),r=t=>n(t)?t:"string"==typeof t?e(t):[t],o=function(n,t){const e=r(t),o=e.length;let u=-1,c=n;for(;++u<o;)if(c=c[e[u]],null==c)return;return c},u=function(t,e,o){if(!(n=>{if(null==n)return!1;const t=typeof n;return"object"==t||"function"==t})(t))return t;const u=r(o),c=u.length,i=c-1,l={...t};let f=l,s=-1;for(;++s<c;){const t=u[s];if(s==i)f[t]=e;else{const e=f[t],r=n(e)?e.slice():{...e};f[t]=r,f=r}}return l},c=Symbol.for("placeholder"),i=function(n,t,e){return t==c?((n,t)=>function(e){return n(e,t)})(n,e):((n,t)=>function(e){return n(t,e)})(n,t)},l=function(n,t){if(null==n)return n;const e=t.length;let r={},c=-1;for(;++c<e;){const e=t[c],i=o(n,e);null!=i&&(r=u(r,i,e))}return r};return function(n,t){return null==t?i(l,c,n):null!=(e=n)&&"function"==typeof e.then?n.then(i(l,c,t)):l(n,t);var e}}());