rubico
Version:
[a]synchronous functional programming
9 lines (8 loc) • 788 B
JavaScript
/**
* 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,u)=>function(e){return r(e,n,u)},curry3ResolveArg1=(r,n,u)=>function(e){return r(n,e,u)},curry3ResolveArg2=(r,n,u)=>function(e){return r(n,u,e)},curry3=function(r,n,u,e){return n==__?curry3ResolveArg0(r,u,e):u==__?curry3ResolveArg1(r,n,e):curry3ResolveArg2(r,n,u)},thunkConditional=(r,n,u)=>r?n():u(),unless=(r,n)=>function(u){const e=r(u);return isPromise(e)?e.then(curry3(thunkConditional,__,always(u),thunkify1(n,u))):e?u:n(u)};export default unless;