0.1.1-0 • Published 3 years ago

@klipitkas/await-to v0.1.1-0

Weekly downloads
-
License
ISC
Repository
-
Last release
3 years ago

await-to

Solve the try-catch hell using golang style error handling.

Install

npm i @klipitkas/await-to --save

Usage

import { to } from 'await-to';

const doSomething = () => {
  const [ data, error ] = await to(resolveOrRejectSomePromise());

  if (error) {
    throw new Error("Whoops!");
  }

  return data;
}

Test

npm run test