Skip to content

sequencer - a deno 🦕 module for sequential promises

License

Notifications You must be signed in to change notification settings

bKiraly/sequencer

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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 test

Format code

deno fmt

Resources

About

sequencer - a deno 🦕 module for sequential promises

Resources

License

Stars

Watchers

Forks

Packages

No packages published