UNPKG

rubico

Version:

[a]synchronous functional programming

8 lines (7 loc) 785 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 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;