UNPKG

rubico

Version:

[a]synchronous functional programming

8 lines (7 loc) 849 B
/** * rubico v2.6.2 * https://github.com/a-synchronous/rubico * (c) 2019-2024 Richard Tong * rubico may be freely distributed under the MIT license. */ const isArray=Array.isArray,isPromise=r=>null!=r&&"function"==typeof r.then,areAnyValuesPromises=function(r){if(isArray(r)){const e=r.length;let n=-1;for(;++n<e;){const e=r[n];if(isPromise(e))return!0}return!1}for(const e in r){const n=r[e];if(isPromise(n))return!0}return!1},promiseAll=Promise.all.bind(Promise),__=Symbol.for("placeholder"),curry2ResolveArg0=(r,e)=>function(n){return r(n,e)},curry2ResolveArg1=(r,e)=>function(n){return r(e,n)},curry2=function(r,e,n){return e==__?curry2ResolveArg0(r,n):curry2ResolveArg1(r,e)},funcApply=(r,e)=>r(...e),thunkify=(r,...e)=>function(){return areAnyValuesPromises(e)?promiseAll(e).then(curry2(funcApply,r,__)):r(...e)};export default thunkify;