wrap-with-promise

Wrap a function with a promise.

Usage no npm install needed!

<script type="module">
  import wrapWithPromise from 'https://cdn.skypack.dev/wrap-with-promise';
</script>

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