rubico
Version:
[a]synchronous functional programming
8 lines (7 loc) • 1.19 kB
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 isArray=Array.isArray,isPromise=r=>null!=r&&"function"==typeof r.then,areAnyValuesPromises=function(r){if(isArray(r)){const n=r.length;let e=-1;for(;++e<n;){const n=r[e];if(isPromise(n))return!0}return!1}for(const n in r){const e=r[n];if(isPromise(e))return!0}return!1},promiseAll=Promise.all.bind(Promise),__=Symbol.for("placeholder"),curry2ResolveArg0=(r,n)=>function(e){return r(e,n)},curry2ResolveArg1=(r,n)=>function(e){return r(n,e)},curry2=function(r,n,e){return n==__?curry2ResolveArg0(r,e):curry2ResolveArg1(r,n)},curryArgs2ResolveArgs0=(r,n,e)=>function(...e){return r(e,n)},curryArgs2ResolveArgs1=(r,n,e)=>function(...e){return r(n,e)},curryArgs2=function(r,n,e){return n==__?curryArgs2ResolveArgs0(r,e):curryArgs2ResolveArgs1(r,n)},negate=r=>!r,_not=function(r,n){const e=n(...r);return isPromise(e)?e.then(negate):!e},not=function(...r){const n=r.pop();return"function"==typeof n?0==r.length?curryArgs2(_not,__,n):areAnyValuesPromises(r)?promiseAll(r).then(curry2(_not,__,n)):_not(r,n):!n};export default not;