Repository
Current version released
5 years ago
Versions
sequencer - a deno π¦ module for sequential promises
Deno promise sequencing.
Usage
To execute promises sequentially, simply add the functions returning the
promises to an array, and call await seq(array). Your promises will be
executed one sequentially! π¦
import { seq } from "https://deno.land/x/sequencer/mod.ts";
const sleep = (t: number) => new Promise((res) => setTimeout(res, t));
let acc: Array<number> = [];
await seq([
() => sleep(10).then(() => acc.push(1)),
() => sleep(20).then(() => acc.push(2)),
() => sleep(1).then(() => acc.push(3)),
]);
console.log(acc); // > [ 1, 2, 3 ]Test
deno testFormat code
deno fmt