wrap-with-promise

0.1.0 • Public • Published

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

Package Sidebar

Install

npm i wrap-with-promise

Weekly Downloads

2

Version

0.1.0

License

MIT

Unpacked Size

1.27 kB

Total Files

3

Last publish

Collaborators

  • andrewmusgrave