rubico
Version:
[a]synchronous functional programming
9 lines (7 loc) • 947 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.
*/
!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=(n,t,e,r)=>function(){return n(t,e,r)},u=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 f=>function(i){const c=i.length;let l=-1;for(;++l<c;){const c=f(i[l]);if(n(c))return c.then((s=t,a=e,h=r(l),y=o(u,f,i,l),a==e?((n,t,e)=>function(r){return n(r,t,e)})(s,h,y):h==e?((n,t,e)=>function(r){return n(t,r,e)})(s,a,y):((n,t,e)=>function(r){return n(t,e,r)})(s,a,h)));if(c)return l}var s,a,h,y;return-1}}());