ciorent
Version:
A lightweight, low-overhead concurrency library
1 lines • 392 B
JavaScript
import{sleep}from"./index.js";export let init=()=>[false];export let any=(...e)=>{let a=[false];for(let o=0;o<e.length;o++)e[o].push(a);return a};export let aborted=e=>e[0];export let abort=e=>{if(!e[0]){e[0]=true;if(e.length>1)for(let a=1;a<e.length;a++)abort(e[a])}};export let abortAfter=async(a,o)=>{await sleep(a);abort(o)};export let timeout=e=>{let a=[false];abortAfter(e,a);return a};