wrap-with-promise
v0.1.0
Published
Wrap a function with a promise
Downloads
4
Maintainers
Readme
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