0.1.0 • Published 6 years ago

wrap-with-promise v0.1.0

Weekly downloads
4
License
MIT
Repository
github
Last release
6 years ago

wrapWithPromise

Wrap a function with a promise.

Install

npm install wrap-with-promise

Usage

// functions
const a = b => b;
const b = () => {
  throw new Error("General error");
};

// wrapped functions
const newA = wrapWithPromise(a);
const newB = wrapWithPromise(b);

// usage
newA("Hello world").then(data => console.log(data)); // Hello world
newB().catch(err => console.log(err)); // Error: General error