Utility for delayed promise rejection handling
npm install delayed-promiseconst wrap = require('delayed-promise');
async function example() {
// Wrap a promise to retrieve it's state later:
const unwrap = wrap(promise);
// ...Other async code...
// Unwrap the promise & retrieve it's state:
await unwrap();
}Wraps a promise or a value to store it's state in the back.
- value
<any>- If a promise, it will be wrapped, if a value, the unwrap function will return a promise that resolves to this value. - returns
<function>- The unwrapping function as described below.
Returns a promise that,
- resolves when the wrapped promise resolves.
- rejects when the wrapped promise rejects.
- resolves to a value if the value passed to
wrap(..)was not a promise.
npm install
npm test