UNPKG

rubico

Version:

[a]synchronous functional programming

9 lines (8 loc) 784 B
/** * Rubico v2.8.2 * https://rubico.land/ * * © Richard Yufei Tong, King of Software * Rubico may be freely distributed under the CFOSS license. */ const isPromise=r=>null!=r&&"function"==typeof r.then,always=r=>function(){return r},__=Symbol.for("placeholder"),thunkify1=(r,n)=>function(){return r(n)},curry3ResolveArg0=(r,n,e)=>function(u){return r(u,n,e)},curry3ResolveArg1=(r,n,e)=>function(u){return r(n,u,e)},curry3ResolveArg2=(r,n,e)=>function(u){return r(n,e,u)},curry3=function(r,n,e,u){return n==__?curry3ResolveArg0(r,e,u):e==__?curry3ResolveArg1(r,n,u):curry3ResolveArg2(r,n,e)},thunkConditional=(r,n,e)=>r?n():e(),when=(r,n)=>function(e){const u=r(e);return isPromise(u)?u.then(curry3(thunkConditional,__,thunkify1(n,e),always(e))):u?n(e):e};export default when;