UNPKG

rubico

Version:

[a]synchronous functional programming

9 lines (7 loc) 1.14 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.assign=t}("object"==typeof globalThis?globalThis:this,function(){"use strict";const n=n=>null!=n&&"function"==typeof n.then,t=Object.assign,o=Symbol.for("placeholder"),e=function(n,t,e){return t==o?((n,t)=>function(o){return n(o,t)})(n,e):((n,t)=>function(o){return n(t,o)})(n,t)},u=function(n,t,e,u){return t==o?((n,t,o)=>function(e){return n(e,t,o)})(n,e,u):e==o?((n,t,o)=>function(e){return n(t,e,o)})(n,t,u):((n,t,o)=>function(e){return n(t,o,e)})(n,t,e)},r=Promise.all.bind(Promise),i=function(n,t,o){return n[t]=o,n},c=function(e,c){const f=function(t,e){const c={},f=[];for(const r in t){const s=t[r],l="function"==typeof s?s(...e):s;n(l)?f.push(l.then(u(i,c,r,o))):c[r]=l}return 0==f.length?c:r(f).then((s=c,function(){return s}));var s}(c,[e]);return n(f)?f.then(u(t,{},e,o)):{...e,...f}};return function(t,u){return null==u?e(c,o,t):n(t)?t.then(e(c,o,u)):c(t,u)}}());