0.1.0 • Published 6 years ago
wrap-with-promise v0.1.0
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
0.1.0
6 years ago