Skip to content

Latest commit

 

History

History
27 lines (17 loc) · 366 Bytes

README.md

File metadata and controls

27 lines (17 loc) · 366 Bytes

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