1 |
|
2 |
|
3 |
|
4 |
|
5 | (function(define) { 'use strict';
|
6 | define(function() {
|
7 |
|
8 | return {
|
9 | pending: toPendingState,
|
10 | fulfilled: toFulfilledState,
|
11 | rejected: toRejectedState,
|
12 | inspect: inspect
|
13 | };
|
14 |
|
15 | function toPendingState() {
|
16 | return { state: 'pending' };
|
17 | }
|
18 |
|
19 | function toRejectedState(e) {
|
20 | return { state: 'rejected', reason: e };
|
21 | }
|
22 |
|
23 | function toFulfilledState(x) {
|
24 | return { state: 'fulfilled', value: x };
|
25 | }
|
26 |
|
27 | function inspect(handler) {
|
28 | var state = handler.state();
|
29 | return state === 0 ? toPendingState()
|
30 | : state > 0 ? toFulfilledState(handler.value)
|
31 | : toRejectedState(handler.value);
|
32 | }
|
33 |
|
34 | });
|
35 | }(typeof define === 'function' && define.amd ? define : function(factory) { module.exports = factory(); }));
|