UNPKG

eve

Version:

Filesystem-first framework for durable backend AI agents that run anywhere.

1 lines 550 B
function createChannelReader(e,t){return{channel:e,iterator:t[Symbol.asyncIterator](),landed:[]}}async function raceChannelReads(e,t){for(;;){for(let t of e){if(t.failure!==void 0)throw t.failure.error;let e=t.landed.shift();if(e!==void 0)return{channel:t.channel,next:e}}let n=[];for(let t of e)t.pending??=t.iterator.next().then(e=>{t.landed.push(e),t.pending=void 0},e=>{t.failure={error:e},t.pending=void 0}),n.push(t.pending);if(t!==void 0&&n.push(t),await Promise.race(n)===`cancel`)return`cancel`}}export{createChannelReader,raceChannelReads};