import { config } from './config'; import instrument from './instrument'; import { noop, subscribe, FULFILLED, REJECTED, PENDING, invokeCallback } from './-internal'; export default function then(onFulfillment, onRejection, label) { let parent = this; let state = parent._state; if (state === FULFILLED && !onFulfillment || state === REJECTED && !onRejection) { config.instrument && instrument('chained', parent, parent); return parent; } parent._onError = null; let child = new parent.constructor(noop, label); let result = parent._result; config.instrument && instrument('chained', parent, child); if (state === PENDING) { subscribe(parent, child, onFulfillment, onRejection); } else { let callback = state === FULFILLED ? onFulfillment : onRejection; config.async(() => invokeCallback(state, child, callback, result)); } return child; }
Name | Type | Size | Permission | Actions |
---|---|---|---|---|
promise | Folder | 0755 |
|
|
-internal.js | File | 5.6 KB | 0644 |
|
all-settled.js | File | 2.34 KB | 0644 |
|
all.js | File | 328 B | 0644 |
|
asap.js | File | 2.86 KB | 0644 |
|
config.js | File | 278 B | 0644 |
|
defer.js | File | 1.13 KB | 0644 |
|
enumerator.js | File | 2.92 KB | 0644 |
|
events.js | File | 4.85 KB | 0644 |
|
filter.js | File | 3.77 KB | 0644 |
|
hash-settled.js | File | 3.83 KB | 0644 |
|
hash.js | File | 2.73 KB | 0644 |
|
instrument.js | File | 971 B | 0644 |
|
map.js | File | 3.08 KB | 0644 |
|
node.js | File | 6.79 KB | 0644 |
|
platform.js | File | 262 B | 0644 |
|
promise-hash.js | File | 1014 B | 0644 |
|
promise.js | File | 10.32 KB | 0644 |
|
race.js | File | 333 B | 0644 |
|
reject.js | File | 466 B | 0644 |
|
resolve.js | File | 484 B | 0644 |
|
rethrow.js | File | 1.43 KB | 0644 |
|
then.js | File | 903 B | 0644 |
|
utils.js | File | 763 B | 0644 |
|