Skip to content
/ waterfall Public

A simple ``try-catch`` block that allows the use of ``throw`` whilst being asynchronous. This utilizes ``async/waterfall``.

License

Notifications You must be signed in to change notification settings

dxgi/waterfall

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

16 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

await-waterfall

A simple try-catch block that allows the use of throw whilst being asynchronous. This utilizes async/waterfall.

import waterfall from 'await-waterfall';

const delay = (ms: number) => new Promise(resolve => setTimeout(resolve, ms));

waterfall<String>([
  async () => {
    await delay(1000);

    return "Hello World!";
  },
  async (str: String) => {
    if (str)
      throw new Error("I GOT IT!");

    return "I DID NOT GET IT!";
  }
], (err, str) => {
  console.log(err, str) // "I GOT IT", null
});

About

A simple ``try-catch`` block that allows the use of ``throw`` whilst being asynchronous. This utilizes ``async/waterfall``.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published