es-promise-ext
Version:
Native promise extensions for javascript and typescript.
21 lines (20 loc) • 452 B
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.default = reject;
/**
* Reject with error in the promise chain.
*
* @param {any} reason
* - the reason of the error
*
* @return {RejectFunction}
* The error which throw in the promise
*
* @example
* Promise.resolve()
* .then(reject('a'))
* .catch(error => console.error(error))
*/
function reject(reason) {
return () => Promise.reject(reason);
}