UNPKG

rubico

Version:

[a]synchronous functional programming

9 lines (7 loc) 910 B
/** * 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.compose=t}("object"==typeof globalThis?globalThis:this,function(){"use strict";const n=Symbol.for("placeholder"),t=Promise.all.bind(Promise),o=(n,t)=>n(...t),e=Array.isArray,r=n=>null!=n&&"function"==typeof n.then,i=(n,t)=>function(...o){const e=n(...o);return r(e)?e.then(t):t(e)};return function(...u){const c=u.pop().reduceRight(i);return 0==u.length?c:function(n){if(e(n)){const t=n.length;let o=-1;for(;++o<t;){const t=n[o];if(r(t))return!0}return!1}for(const t in n){const o=n[t];if(r(o))return!0}return!1}(u)?t(u).then((f=o,l=n,(s=c)==n?((n,t)=>function(o){return n(o,t)})(f,l):((n,t)=>function(o){return n(t,o)})(f,s))):c(...u);var f,s,l}}());