rubico
Version:
[a]synchronous functional programming
10 lines (8 loc) • 953 B
JavaScript
/**
* Rubico v2.8.2
* https://rubico.land/
*
* © Richard Yufei Tong, King of Software
* Rubico may be freely distributed under the CFOSS license.
*/
!function(n,t){"object"==typeof module?module.exports=t:"function"==typeof define?define(()=>t):n.findIndex=t}("object"==typeof globalThis?globalThis:this,function(){"use strict";Array.isArray;const n=n=>null!=n&&"function"==typeof n.then,t=(n,t,e)=>n?t():e(),e=Symbol.for("placeholder"),r=n=>function(){return n},o=function(n,t,r,o){return t==e?((n,t,e)=>function(r){return n(r,t,e)})(n,r,o):r==e?((n,t,e)=>function(r){return n(t,r,e)})(n,t,o):((n,t,e)=>function(r){return n(t,e,r)})(n,t,r)},u=(n,t,e,r)=>function(){return n(t,e,r)},f=async function(t,e,r){const o=e.length;for(;++r<o;){let o=t(e[r]);if(n(o)&&(o=await o),o)return r}return-1};return i=>function(c){const l=c.length;let s=-1;for(;++s<l;){const l=i(c[s]);if(n(l))return l.then(o(t,e,r(s),u(f,i,c,s)));if(l)return s}return-1}}());