import { invokeCallback, subscribe, FULFILLED, REJECTED, noop, makePromise, PROMISE_ID } from './-internal'; import { asap } from './asap'; export default function then(onFulfillment, onRejection) { const parent = this; const child = new this.constructor(noop); if (child[PROMISE_ID] === undefined) { makePromise(child); } const { _state } = parent; if (_state) { const callback = arguments[_state - 1]; asap(() => invokeCallback(_state, child, callback, parent._result)); } else { subscribe(parent, child, onFulfillment, onRejection); } return child; }
Name | Type | Size | Permission | Actions |
---|---|---|---|---|
promise | Folder | 0755 |
|
|
-internal.js | File | 5.19 KB | 0644 |
|
asap.js | File | 3.1 KB | 0644 |
|
enumerator.js | File | 2.78 KB | 0644 |
|
polyfill.js | File | 724 B | 0644 |
|
promise.js | File | 9.81 KB | 0644 |
|
then.js | File | 609 B | 0644 |
|
utils.js | File | 468 B | 0644 |
|