rubico
Version:
[a]synchronous functional programming
10 lines (8 loc) • 958 B
JavaScript
/**
* Rubico v2.8.2
* https://rubico.land/
*
* © Richard Yufei Tong, King of Software
* Rubico may be freely distributed under the CFOSS 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}}());