7 `Promise.reject` returns a promise rejected with the passed `reason`.
8 It is shorthand for the following:
11 let promise = new Promise(function(resolve, reject){
12 reject(new Error('WHOOPS'));
15 promise.then(function(value){
16 // Code here doesn't run because the promise is rejected!
18 // reason.message === 'WHOOPS'
22 Instead of writing the above, your code now simply becomes the following:
25 let promise = Promise.reject(new Error('WHOOPS'));
27 promise.then(function(value){
28 // Code here doesn't run because the promise is rejected!
30 // reason.message === 'WHOOPS'
36 @param {Any} reason value that the returned promise will be rejected with.
38 @return {Promise} a promise rejected with the given `reason`.
40 export default function reject(reason) {
41 /*jshint validthis:true */
42 let Constructor = this;
43 let promise = new Constructor(noop);
44 _reject(promise, reason);