rubico
Version:
[a]synchronous functional programming
10 lines (8 loc) • 1.01 kB
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.thunkify=t}("object"==typeof globalThis?globalThis:this,function(){"use strict";const n=Array.isArray,t=n=>null!=n&&"function"==typeof n.then,r=function(r){if(n(r)){const n=r.length;let o=-1;for(;++o<n;){const n=r[o];if(t(n))return!0}return!1}for(const n in r){const o=r[n];if(t(o))return!0}return!1},o=Promise.all.bind(Promise),e=Symbol.for("placeholder"),u=function(n,t,r,o){return t==e?((n,t,r)=>function(o){return n(o,t,r)})(n,r,o):r==e?((n,t,r)=>function(o){return n(t,o,r)})(n,t,o):((n,t,r)=>function(o){return n(t,r,o)})(n,t,r)};function i(n,t,r){return function(){return n.apply(t,r)}}const f=function(n,...t){return r(t)?o(t).then(u(i,n,this,e)):i(n,this,t)};return f.call=function(n,t,...f){return r(f)?o(f).then(u(i,n,t,e)):i(n,t,f)},f}());