rubico
Version:
[a]synchronous functional programming
9 lines (7 loc) • 1.8 kB
JavaScript
/**
* 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.gte=t}("object"==typeof globalThis?globalThis:this,function(){"use strict";const n=n=>null!=n&&"function"==typeof n.then,t=Array.isArray,e=function(e){if(t(e)){const t=e.length;let o=-1;for(;++o<t;){const t=e[o];if(n(t))return!0}return!1}for(const t in e){const o=e[t];if(n(o))return!0}return!1},o=Symbol.for("placeholder"),r=function(n,t,e,r,u){return t==o?((n,t,e,o)=>function(r){return n(r,t,e,o)})(n,e,r,u):e==o?((n,t,e,o)=>function(r){return n(t,r,e,o)})(n,t,r,u):r==o?((n,t,e,o)=>function(r){return n(t,e,r,o)})(n,t,e,u):((n,t,e,o)=>function(r){return n(t,e,o,r)})(n,t,e,r)},u=function(n,t,e,r,u){return t==o?((n,t,e,o)=>function(...r){return n(r,t,e,o)})(n,e,r,u):e==o?((n,t,e,o)=>function(...r){return n(t,r,e,o)})(n,t,r,u):r==o?((n,t,e,o)=>function(...r){return n(t,e,r,o)})(n,t,e,u):((n,t,e,o)=>function(...r){return n(t,e,o,r)})(n,t,e,r)},f=n=>function([t,e]){return n(t,e)},i=Promise.all.bind(Promise),c=function(t,e,o,r){const u=o(...t),c=r(...t);return n(u)||n(c)?i([u,c]).then(f(e)):e(u,c)},l=function(t,e,o,r){const u=o(...t);return n(u)||n(r)?i([u,r]).then(f(e)):e(u,r)},s=function(t,e,o,r){const u=r(...t);return n(o)||n(u)?i([o,u]).then(f(e)):e(o,u)};var h;return h=(n,t)=>n>=t,function(...t){const p=t.pop(),y=t.pop(),a="function"==typeof y,g="function"==typeof p;return a&&g?0==t.length?u(c,o,h,y,p):e(t)?i(t).then(r(c,o,h,y,p)):c(t,h,y,p):a?0==t.length?u(l,o,h,y,p):e(t)?i(t).then(r(l,o,h,y,p)):l(t,h,y,p):g?0==t.length?u(s,o,h,y,p):e(t)?i(t).then(r(s,o,h,y,p)):s(t,h,y,p):n(y)||n(p)?i([y,p]).then(f(h)):h(y,p)}}());