flat-await

1.0.0 • Public • Published

flat-await

When working with async/await, we usually have to do this:

async function foo() {
  try {
    const bar = await baz();
    . . .
  } catch (e) {
    console.error(e);
  }
}

That sucks. Instead, flat-await lets you do this:

import p from 'flat-await';

async function foo() {
  const [err, bar] = await p(baz());
  if (err) throw err;
  . . .
}

Re-throwing the error will propagate it out, or you can do something else more appropriate.

Versions

Current Tags

  • Version
    Downloads (Last 7 Days)
    • Tag
  • 1.0.0
    0
    • latest

Version History

  • Version
    Downloads (Last 7 Days)
    • Published
  • 1.0.0
    0

Package Sidebar

Install

npm i flat-await

Weekly Downloads

0

Version

1.0.0

License

ISC

Unpacked Size

2.47 kB

Total Files

6

Last publish

Collaborators

  • johnhalbert