Iterates over an async iterable or array, calling fn for each value, with optional
interval between each loop. If the async fn returns false, iterator cancels.
import { forEach } from"https://unpkg.com/ixfx/dist/flow.js" // Prints items from array every second awaitforEach([0,1,2,3], i=>console.log(i), 1000);
// Retry up to five times, with 5 seconds between each attempt awaitforEach(count(5), i=> { try { awaitdoSomething(); returnfalse; // Succeeded, exit early } catch (ex) { console.log(ex); returntrue; // Keep trying } }, 5000);
Iterates over an async iterable or array, calling
fn
for each value, with optional interval between each loop. If the asyncfn
returns false, iterator cancels.