执行过npm install命令的vue-element-admin源码
康凯
2022-05-20 aa4c235a8ca67ea8b731f90c951a465e92c0a865
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
import {
  noop,
  reject as _reject
} from '../-internal';
 
/**
  `Promise.reject` returns a promise rejected with the passed `reason`.
  It is shorthand for the following:
 
  ```javascript
  import Promise from 'rsvp';
 
  let promise = new Promise(function(resolve, reject){
    reject(new Error('WHOOPS'));
  });
 
  promise.then(function(value){
    // Code here doesn't run because the promise is rejected!
  }, function(reason){
    // reason.message === 'WHOOPS'
  });
  ```
 
  Instead of writing the above, your code now simply becomes the following:
 
  ```javascript
  import Promise from 'rsvp';
 
  let promise = Promise.reject(new Error('WHOOPS'));
 
  promise.then(function(value){
    // Code here doesn't run because the promise is rejected!
  }, function(reason){
    // reason.message === 'WHOOPS'
  });
  ```
 
  @method reject
  @for Promise
  @static
  @param {*} reason value that the returned promise will be rejected with.
  @param {String} [label] optional string for identifying the returned promise.
  Useful for tooling.
  @return {Promise} a promise rejected with the given `reason`.
*/
export default function reject(reason, label) {
  /*jshint validthis:true */
  let Constructor = this;
  let promise = new Constructor(noop, label);
  _reject(promise, reason);
  return promise;
}