rubico
Version:
[a]synchronous functional programming
8 lines (7 loc) • 789 B
JavaScript
/**
* 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,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;