UNPKG

rubico

Version:

[a]synchronous functional programming

9 lines (7 loc) 961 B
/** * rubico v2.7.7 * https://github.com/a-synchronous/rubico * (c) 2019-2025 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),e=(n,t)=>n(...t),o=Array.isArray,r=n=>null!=n&&"function"==typeof n.then,i=(n,t)=>function(...e){const o=n(...e);return r(o)?o.then(t):t(o)};return function(...u){if("function"==typeof u[0])return u.reduceRight(i);const c=u.pop().reduceRight(i);return 0==u.length?c:function(n){if(o(n)){const t=n.length;let e=-1;for(;++e<t;){const t=n[e];if(r(t))return!0}return!1}for(const t in n){const e=n[t];if(r(e))return!0}return!1}(u)?t(u).then((f=e,l=n,(s=c)==n?((n,t)=>function(e){return n(e,t)})(f,l):((n,t)=>function(e){return n(t,e)})(f,s))):c(...u);var f,s,l}}());