rubico
Version:
[a]synchronous functional programming
9 lines (7 loc) • 1.81 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.eq=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 r=-1;for(;++r<t;){const t=e[r];if(n(t))return!0}return!1}for(const t in e){const r=e[t];if(n(r))return!0}return!1},r=Symbol.for("placeholder"),o=function(n,t,e,o,u){return t==r?((n,t,e,r)=>function(o){return n(o,t,e,r)})(n,e,o,u):e==r?((n,t,e,r)=>function(o){return n(t,o,e,r)})(n,t,o,u):o==r?((n,t,e,r)=>function(o){return n(t,e,o,r)})(n,t,e,u):((n,t,e,r)=>function(o){return n(t,e,r,o)})(n,t,e,o)},u=function(n,t,e,o,u){return t==r?((n,t,e,r)=>function(...o){return n(o,t,e,r)})(n,e,o,u):e==r?((n,t,e,r)=>function(...o){return n(t,o,e,r)})(n,t,o,u):o==r?((n,t,e,r)=>function(...o){return n(t,e,o,r)})(n,t,e,u):((n,t,e,r)=>function(...o){return n(t,e,r,o)})(n,t,e,o)},f=n=>function([t,e]){return n(t,e)},i=Promise.all.bind(Promise),c=function(t,e,r,o){const u=r(...t),c=o(...t);return n(u)||n(c)?i([u,c]).then(f(e)):e(u,c)},l=function(t,e,r,o){const u=r(...t);return n(u)||n(o)?i([u,o]).then(f(e)):e(u,o)},s=function(t,e,r,o){const u=o(...t);return n(r)||n(u)?i([r,u]).then(f(e)):e(r,u)};var h;return h=function(n,t){return n==t},function(...t){const p=t.pop(),y=t.pop(),a="function"==typeof y,b="function"==typeof p;return a&&b?0==t.length?u(c,r,h,y,p):e(t)?i(t).then(o(c,r,h,y,p)):c(t,h,y,p):a?0==t.length?u(l,r,h,y,p):e(t)?i(t).then(o(l,r,h,y,p)):l(t,h,y,p):b?0==t.length?u(s,r,h,y,p):e(t)?i(t).then(o(s,r,h,y,p)):s(t,h,y,p):n(y)||n(p)?i([y,p]).then(f(h)):h(y,p)}}());