corrade-nucleus-nucleons – Blame information for rev 20

Subversion Repositories:
Rev:
Rev Author Line No. Line
20 office 1 "use strict";
2 module.exports = function() {
3 var makeSelfResolutionError = function () {
4 return new TypeError("circular promise resolution chain\u000a\u000a See http://goo.gl/MqrFmX\u000a");
5 };
6 var reflectHandler = function() {
7 return new Promise.PromiseInspection(this._target());
8 };
9 var apiRejection = function(msg) {
10 return Promise.reject(new TypeError(msg));
11 };
12 function Proxyable() {}
13 var UNDEFINED_BINDING = {};
14 var util = require("./util");
15  
16 var getDomain;
17 if (util.isNode) {
18 getDomain = function() {
19 var ret = process.domain;
20 if (ret === undefined) ret = null;
21 return ret;
22 };
23 } else {
24 getDomain = function() {
25 return null;
26 };
27 }
28 util.notEnumerableProp(Promise, "_getDomain", getDomain);
29  
30 var es5 = require("./es5");
31 var Async = require("./async");
32 var async = new Async();
33 es5.defineProperty(Promise, "_async", {value: async});
34 var errors = require("./errors");
35 var TypeError = Promise.TypeError = errors.TypeError;
36 Promise.RangeError = errors.RangeError;
37 var CancellationError = Promise.CancellationError = errors.CancellationError;
38 Promise.TimeoutError = errors.TimeoutError;
39 Promise.OperationalError = errors.OperationalError;
40 Promise.RejectionError = errors.OperationalError;
41 Promise.AggregateError = errors.AggregateError;
42 var INTERNAL = function(){};
43 var APPLY = {};
44 var NEXT_FILTER = {};
45 var tryConvertToPromise = require("./thenables")(Promise, INTERNAL);
46 var PromiseArray =
47 require("./promise_array")(Promise, INTERNAL,
48 tryConvertToPromise, apiRejection, Proxyable);
49 var Context = require("./context")(Promise);
50 /*jshint unused:false*/
51 var createContext = Context.create;
52 var debug = require("./debuggability")(Promise, Context);
53 var CapturedTrace = debug.CapturedTrace;
54 var PassThroughHandlerContext =
55 require("./finally")(Promise, tryConvertToPromise, NEXT_FILTER);
56 var catchFilter = require("./catch_filter")(NEXT_FILTER);
57 var nodebackForPromise = require("./nodeback");
58 var errorObj = util.errorObj;
59 var tryCatch = util.tryCatch;
60 function check(self, executor) {
61 if (self == null || self.constructor !== Promise) {
62 throw new TypeError("the promise constructor cannot be invoked directly\u000a\u000a See http://goo.gl/MqrFmX\u000a");
63 }
64 if (typeof executor !== "function") {
65 throw new TypeError("expecting a function but got " + util.classString(executor));
66 }
67  
68 }
69  
70 function Promise(executor) {
71 if (executor !== INTERNAL) {
72 check(this, executor);
73 }
74 this._bitField = 0;
75 this._fulfillmentHandler0 = undefined;
76 this._rejectionHandler0 = undefined;
77 this._promise0 = undefined;
78 this._receiver0 = undefined;
79 this._resolveFromExecutor(executor);
80 this._promiseCreated();
81 this._fireEvent("promiseCreated", this);
82 }
83  
84 Promise.prototype.toString = function () {
85 return "[object Promise]";
86 };
87  
88 Promise.prototype.caught = Promise.prototype["catch"] = function (fn) {
89 var len = arguments.length;
90 if (len > 1) {
91 var catchInstances = new Array(len - 1),
92 j = 0, i;
93 for (i = 0; i < len - 1; ++i) {
94 var item = arguments[i];
95 if (util.isObject(item)) {
96 catchInstances[j++] = item;
97 } else {
98 return apiRejection("Catch statement predicate: " +
99 "expecting an object but got " + util.classString(item));
100 }
101 }
102 catchInstances.length = j;
103 fn = arguments[i];
104 return this.then(undefined, catchFilter(catchInstances, fn, this));
105 }
106 return this.then(undefined, fn);
107 };
108  
109 Promise.prototype.reflect = function () {
110 return this._then(reflectHandler,
111 reflectHandler, undefined, this, undefined);
112 };
113  
114 Promise.prototype.then = function (didFulfill, didReject) {
115 if (debug.warnings() && arguments.length > 0 &&
116 typeof didFulfill !== "function" &&
117 typeof didReject !== "function") {
118 var msg = ".then() only accepts functions but was passed: " +
119 util.classString(didFulfill);
120 if (arguments.length > 1) {
121 msg += ", " + util.classString(didReject);
122 }
123 this._warn(msg);
124 }
125 return this._then(didFulfill, didReject, undefined, undefined, undefined);
126 };
127  
128 Promise.prototype.done = function (didFulfill, didReject) {
129 var promise =
130 this._then(didFulfill, didReject, undefined, undefined, undefined);
131 promise._setIsFinal();
132 };
133  
134 Promise.prototype.spread = function (fn) {
135 if (typeof fn !== "function") {
136 return apiRejection("expecting a function but got " + util.classString(fn));
137 }
138 return this.all()._then(fn, undefined, undefined, APPLY, undefined);
139 };
140  
141 Promise.prototype.toJSON = function () {
142 var ret = {
143 isFulfilled: false,
144 isRejected: false,
145 fulfillmentValue: undefined,
146 rejectionReason: undefined
147 };
148 if (this.isFulfilled()) {
149 ret.fulfillmentValue = this.value();
150 ret.isFulfilled = true;
151 } else if (this.isRejected()) {
152 ret.rejectionReason = this.reason();
153 ret.isRejected = true;
154 }
155 return ret;
156 };
157  
158 Promise.prototype.all = function () {
159 if (arguments.length > 0) {
160 this._warn(".all() was passed arguments but it does not take any");
161 }
162 return new PromiseArray(this).promise();
163 };
164  
165 Promise.prototype.error = function (fn) {
166 return this.caught(util.originatesFromRejection, fn);
167 };
168  
169 Promise.getNewLibraryCopy = module.exports;
170  
171 Promise.is = function (val) {
172 return val instanceof Promise;
173 };
174  
175 Promise.fromNode = Promise.fromCallback = function(fn) {
176 var ret = new Promise(INTERNAL);
177 ret._captureStackTrace();
178 var multiArgs = arguments.length > 1 ? !!Object(arguments[1]).multiArgs
179 : false;
180 var result = tryCatch(fn)(nodebackForPromise(ret, multiArgs));
181 if (result === errorObj) {
182 ret._rejectCallback(result.e, true);
183 }
184 if (!ret._isFateSealed()) ret._setAsyncGuaranteed();
185 return ret;
186 };
187  
188 Promise.all = function (promises) {
189 return new PromiseArray(promises).promise();
190 };
191  
192 Promise.cast = function (obj) {
193 var ret = tryConvertToPromise(obj);
194 if (!(ret instanceof Promise)) {
195 ret = new Promise(INTERNAL);
196 ret._captureStackTrace();
197 ret._setFulfilled();
198 ret._rejectionHandler0 = obj;
199 }
200 return ret;
201 };
202  
203 Promise.resolve = Promise.fulfilled = Promise.cast;
204  
205 Promise.reject = Promise.rejected = function (reason) {
206 var ret = new Promise(INTERNAL);
207 ret._captureStackTrace();
208 ret._rejectCallback(reason, true);
209 return ret;
210 };
211  
212 Promise.setScheduler = function(fn) {
213 if (typeof fn !== "function") {
214 throw new TypeError("expecting a function but got " + util.classString(fn));
215 }
216 return async.setScheduler(fn);
217 };
218  
219 Promise.prototype._then = function (
220 didFulfill,
221 didReject,
222 _, receiver,
223 internalData
224 ) {
225 var haveInternalData = internalData !== undefined;
226 var promise = haveInternalData ? internalData : new Promise(INTERNAL);
227 var target = this._target();
228 var bitField = target._bitField;
229  
230 if (!haveInternalData) {
231 promise._propagateFrom(this, 3);
232 promise._captureStackTrace();
233 if (receiver === undefined &&
234 ((this._bitField & 2097152) !== 0)) {
235 if (!((bitField & 50397184) === 0)) {
236 receiver = this._boundValue();
237 } else {
238 receiver = target === this ? undefined : this._boundTo;
239 }
240 }
241 this._fireEvent("promiseChained", this, promise);
242 }
243  
244 var domain = getDomain();
245 if (!((bitField & 50397184) === 0)) {
246 var handler, value, settler = target._settlePromiseCtx;
247 if (((bitField & 33554432) !== 0)) {
248 value = target._rejectionHandler0;
249 handler = didFulfill;
250 } else if (((bitField & 16777216) !== 0)) {
251 value = target._fulfillmentHandler0;
252 handler = didReject;
253 target._unsetRejectionIsUnhandled();
254 } else {
255 settler = target._settlePromiseLateCancellationObserver;
256 value = new CancellationError("late cancellation observer");
257 target._attachExtraTrace(value);
258 handler = didReject;
259 }
260  
261 async.invoke(settler, target, {
262 handler: domain === null ? handler
263 : (typeof handler === "function" &&
264 util.domainBind(domain, handler)),
265 promise: promise,
266 receiver: receiver,
267 value: value
268 });
269 } else {
270 target._addCallbacks(didFulfill, didReject, promise, receiver, domain);
271 }
272  
273 return promise;
274 };
275  
276 Promise.prototype._length = function () {
277 return this._bitField & 65535;
278 };
279  
280 Promise.prototype._isFateSealed = function () {
281 return (this._bitField & 117506048) !== 0;
282 };
283  
284 Promise.prototype._isFollowing = function () {
285 return (this._bitField & 67108864) === 67108864;
286 };
287  
288 Promise.prototype._setLength = function (len) {
289 this._bitField = (this._bitField & -65536) |
290 (len & 65535);
291 };
292  
293 Promise.prototype._setFulfilled = function () {
294 this._bitField = this._bitField | 33554432;
295 this._fireEvent("promiseFulfilled", this);
296 };
297  
298 Promise.prototype._setRejected = function () {
299 this._bitField = this._bitField | 16777216;
300 this._fireEvent("promiseRejected", this);
301 };
302  
303 Promise.prototype._setFollowing = function () {
304 this._bitField = this._bitField | 67108864;
305 this._fireEvent("promiseResolved", this);
306 };
307  
308 Promise.prototype._setIsFinal = function () {
309 this._bitField = this._bitField | 4194304;
310 };
311  
312 Promise.prototype._isFinal = function () {
313 return (this._bitField & 4194304) > 0;
314 };
315  
316 Promise.prototype._unsetCancelled = function() {
317 this._bitField = this._bitField & (~65536);
318 };
319  
320 Promise.prototype._setCancelled = function() {
321 this._bitField = this._bitField | 65536;
322 this._fireEvent("promiseCancelled", this);
323 };
324  
325 Promise.prototype._setWillBeCancelled = function() {
326 this._bitField = this._bitField | 8388608;
327 };
328  
329 Promise.prototype._setAsyncGuaranteed = function() {
330 if (async.hasCustomScheduler()) return;
331 this._bitField = this._bitField | 134217728;
332 };
333  
334 Promise.prototype._receiverAt = function (index) {
335 var ret = index === 0 ? this._receiver0 : this[
336 index * 4 - 4 + 3];
337 if (ret === UNDEFINED_BINDING) {
338 return undefined;
339 } else if (ret === undefined && this._isBound()) {
340 return this._boundValue();
341 }
342 return ret;
343 };
344  
345 Promise.prototype._promiseAt = function (index) {
346 return this[
347 index * 4 - 4 + 2];
348 };
349  
350 Promise.prototype._fulfillmentHandlerAt = function (index) {
351 return this[
352 index * 4 - 4 + 0];
353 };
354  
355 Promise.prototype._rejectionHandlerAt = function (index) {
356 return this[
357 index * 4 - 4 + 1];
358 };
359  
360 Promise.prototype._boundValue = function() {};
361  
362 Promise.prototype._migrateCallback0 = function (follower) {
363 var bitField = follower._bitField;
364 var fulfill = follower._fulfillmentHandler0;
365 var reject = follower._rejectionHandler0;
366 var promise = follower._promise0;
367 var receiver = follower._receiverAt(0);
368 if (receiver === undefined) receiver = UNDEFINED_BINDING;
369 this._addCallbacks(fulfill, reject, promise, receiver, null);
370 };
371  
372 Promise.prototype._migrateCallbackAt = function (follower, index) {
373 var fulfill = follower._fulfillmentHandlerAt(index);
374 var reject = follower._rejectionHandlerAt(index);
375 var promise = follower._promiseAt(index);
376 var receiver = follower._receiverAt(index);
377 if (receiver === undefined) receiver = UNDEFINED_BINDING;
378 this._addCallbacks(fulfill, reject, promise, receiver, null);
379 };
380  
381 Promise.prototype._addCallbacks = function (
382 fulfill,
383 reject,
384 promise,
385 receiver,
386 domain
387 ) {
388 var index = this._length();
389  
390 if (index >= 65535 - 4) {
391 index = 0;
392 this._setLength(0);
393 }
394  
395 if (index === 0) {
396 this._promise0 = promise;
397 this._receiver0 = receiver;
398 if (typeof fulfill === "function") {
399 this._fulfillmentHandler0 =
400 domain === null ? fulfill : util.domainBind(domain, fulfill);
401 }
402 if (typeof reject === "function") {
403 this._rejectionHandler0 =
404 domain === null ? reject : util.domainBind(domain, reject);
405 }
406 } else {
407 var base = index * 4 - 4;
408 this[base + 2] = promise;
409 this[base + 3] = receiver;
410 if (typeof fulfill === "function") {
411 this[base + 0] =
412 domain === null ? fulfill : util.domainBind(domain, fulfill);
413 }
414 if (typeof reject === "function") {
415 this[base + 1] =
416 domain === null ? reject : util.domainBind(domain, reject);
417 }
418 }
419 this._setLength(index + 1);
420 return index;
421 };
422  
423 Promise.prototype._proxy = function (proxyable, arg) {
424 this._addCallbacks(undefined, undefined, arg, proxyable, null);
425 };
426  
427 Promise.prototype._resolveCallback = function(value, shouldBind) {
428 if (((this._bitField & 117506048) !== 0)) return;
429 if (value === this)
430 return this._rejectCallback(makeSelfResolutionError(), false);
431 var maybePromise = tryConvertToPromise(value, this);
432 if (!(maybePromise instanceof Promise)) return this._fulfill(value);
433  
434 if (shouldBind) this._propagateFrom(maybePromise, 2);
435  
436 var promise = maybePromise._target();
437  
438 if (promise === this) {
439 this._reject(makeSelfResolutionError());
440 return;
441 }
442  
443 var bitField = promise._bitField;
444 if (((bitField & 50397184) === 0)) {
445 var len = this._length();
446 if (len > 0) promise._migrateCallback0(this);
447 for (var i = 1; i < len; ++i) {
448 promise._migrateCallbackAt(this, i);
449 }
450 this._setFollowing();
451 this._setLength(0);
452 this._setFollowee(promise);
453 } else if (((bitField & 33554432) !== 0)) {
454 this._fulfill(promise._value());
455 } else if (((bitField & 16777216) !== 0)) {
456 this._reject(promise._reason());
457 } else {
458 var reason = new CancellationError("late cancellation observer");
459 promise._attachExtraTrace(reason);
460 this._reject(reason);
461 }
462 };
463  
464 Promise.prototype._rejectCallback =
465 function(reason, synchronous, ignoreNonErrorWarnings) {
466 var trace = util.ensureErrorObject(reason);
467 var hasStack = trace === reason;
468 if (!hasStack && !ignoreNonErrorWarnings && debug.warnings()) {
469 var message = "a promise was rejected with a non-error: " +
470 util.classString(reason);
471 this._warn(message, true);
472 }
473 this._attachExtraTrace(trace, synchronous ? hasStack : false);
474 this._reject(reason);
475 };
476  
477 Promise.prototype._resolveFromExecutor = function (executor) {
478 if (executor === INTERNAL) return;
479 var promise = this;
480 this._captureStackTrace();
481 this._pushContext();
482 var synchronous = true;
483 var r = this._execute(executor, function(value) {
484 promise._resolveCallback(value);
485 }, function (reason) {
486 promise._rejectCallback(reason, synchronous);
487 });
488 synchronous = false;
489 this._popContext();
490  
491 if (r !== undefined) {
492 promise._rejectCallback(r, true);
493 }
494 };
495  
496 Promise.prototype._settlePromiseFromHandler = function (
497 handler, receiver, value, promise
498 ) {
499 var bitField = promise._bitField;
500 if (((bitField & 65536) !== 0)) return;
501 promise._pushContext();
502 var x;
503 if (receiver === APPLY) {
504 if (!value || typeof value.length !== "number") {
505 x = errorObj;
506 x.e = new TypeError("cannot .spread() a non-array: " +
507 util.classString(value));
508 } else {
509 x = tryCatch(handler).apply(this._boundValue(), value);
510 }
511 } else {
512 x = tryCatch(handler).call(receiver, value);
513 }
514 var promiseCreated = promise._popContext();
515 bitField = promise._bitField;
516 if (((bitField & 65536) !== 0)) return;
517  
518 if (x === NEXT_FILTER) {
519 promise._reject(value);
520 } else if (x === errorObj) {
521 promise._rejectCallback(x.e, false);
522 } else {
523 debug.checkForgottenReturns(x, promiseCreated, "", promise, this);
524 promise._resolveCallback(x);
525 }
526 };
527  
528 Promise.prototype._target = function() {
529 var ret = this;
530 while (ret._isFollowing()) ret = ret._followee();
531 return ret;
532 };
533  
534 Promise.prototype._followee = function() {
535 return this._rejectionHandler0;
536 };
537  
538 Promise.prototype._setFollowee = function(promise) {
539 this._rejectionHandler0 = promise;
540 };
541  
542 Promise.prototype._settlePromise = function(promise, handler, receiver, value) {
543 var isPromise = promise instanceof Promise;
544 var bitField = this._bitField;
545 var asyncGuaranteed = ((bitField & 134217728) !== 0);
546 if (((bitField & 65536) !== 0)) {
547 if (isPromise) promise._invokeInternalOnCancel();
548  
549 if (receiver instanceof PassThroughHandlerContext &&
550 receiver.isFinallyHandler()) {
551 receiver.cancelPromise = promise;
552 if (tryCatch(handler).call(receiver, value) === errorObj) {
553 promise._reject(errorObj.e);
554 }
555 } else if (handler === reflectHandler) {
556 promise._fulfill(reflectHandler.call(receiver));
557 } else if (receiver instanceof Proxyable) {
558 receiver._promiseCancelled(promise);
559 } else if (isPromise || promise instanceof PromiseArray) {
560 promise._cancel();
561 } else {
562 receiver.cancel();
563 }
564 } else if (typeof handler === "function") {
565 if (!isPromise) {
566 handler.call(receiver, value, promise);
567 } else {
568 if (asyncGuaranteed) promise._setAsyncGuaranteed();
569 this._settlePromiseFromHandler(handler, receiver, value, promise);
570 }
571 } else if (receiver instanceof Proxyable) {
572 if (!receiver._isResolved()) {
573 if (((bitField & 33554432) !== 0)) {
574 receiver._promiseFulfilled(value, promise);
575 } else {
576 receiver._promiseRejected(value, promise);
577 }
578 }
579 } else if (isPromise) {
580 if (asyncGuaranteed) promise._setAsyncGuaranteed();
581 if (((bitField & 33554432) !== 0)) {
582 promise._fulfill(value);
583 } else {
584 promise._reject(value);
585 }
586 }
587 };
588  
589 Promise.prototype._settlePromiseLateCancellationObserver = function(ctx) {
590 var handler = ctx.handler;
591 var promise = ctx.promise;
592 var receiver = ctx.receiver;
593 var value = ctx.value;
594 if (typeof handler === "function") {
595 if (!(promise instanceof Promise)) {
596 handler.call(receiver, value, promise);
597 } else {
598 this._settlePromiseFromHandler(handler, receiver, value, promise);
599 }
600 } else if (promise instanceof Promise) {
601 promise._reject(value);
602 }
603 };
604  
605 Promise.prototype._settlePromiseCtx = function(ctx) {
606 this._settlePromise(ctx.promise, ctx.handler, ctx.receiver, ctx.value);
607 };
608  
609 Promise.prototype._settlePromise0 = function(handler, value, bitField) {
610 var promise = this._promise0;
611 var receiver = this._receiverAt(0);
612 this._promise0 = undefined;
613 this._receiver0 = undefined;
614 this._settlePromise(promise, handler, receiver, value);
615 };
616  
617 Promise.prototype._clearCallbackDataAtIndex = function(index) {
618 var base = index * 4 - 4;
619 this[base + 2] =
620 this[base + 3] =
621 this[base + 0] =
622 this[base + 1] = undefined;
623 };
624  
625 Promise.prototype._fulfill = function (value) {
626 var bitField = this._bitField;
627 if (((bitField & 117506048) >>> 16)) return;
628 if (value === this) {
629 var err = makeSelfResolutionError();
630 this._attachExtraTrace(err);
631 return this._reject(err);
632 }
633 this._setFulfilled();
634 this._rejectionHandler0 = value;
635  
636 if ((bitField & 65535) > 0) {
637 if (((bitField & 134217728) !== 0)) {
638 this._settlePromises();
639 } else {
640 async.settlePromises(this);
641 }
642 }
643 };
644  
645 Promise.prototype._reject = function (reason) {
646 var bitField = this._bitField;
647 if (((bitField & 117506048) >>> 16)) return;
648 this._setRejected();
649 this._fulfillmentHandler0 = reason;
650  
651 if (this._isFinal()) {
652 return async.fatalError(reason, util.isNode);
653 }
654  
655 if ((bitField & 65535) > 0) {
656 async.settlePromises(this);
657 } else {
658 this._ensurePossibleRejectionHandled();
659 }
660 };
661  
662 Promise.prototype._fulfillPromises = function (len, value) {
663 for (var i = 1; i < len; i++) {
664 var handler = this._fulfillmentHandlerAt(i);
665 var promise = this._promiseAt(i);
666 var receiver = this._receiverAt(i);
667 this._clearCallbackDataAtIndex(i);
668 this._settlePromise(promise, handler, receiver, value);
669 }
670 };
671  
672 Promise.prototype._rejectPromises = function (len, reason) {
673 for (var i = 1; i < len; i++) {
674 var handler = this._rejectionHandlerAt(i);
675 var promise = this._promiseAt(i);
676 var receiver = this._receiverAt(i);
677 this._clearCallbackDataAtIndex(i);
678 this._settlePromise(promise, handler, receiver, reason);
679 }
680 };
681  
682 Promise.prototype._settlePromises = function () {
683 var bitField = this._bitField;
684 var len = (bitField & 65535);
685  
686 if (len > 0) {
687 if (((bitField & 16842752) !== 0)) {
688 var reason = this._fulfillmentHandler0;
689 this._settlePromise0(this._rejectionHandler0, reason, bitField);
690 this._rejectPromises(len, reason);
691 } else {
692 var value = this._rejectionHandler0;
693 this._settlePromise0(this._fulfillmentHandler0, value, bitField);
694 this._fulfillPromises(len, value);
695 }
696 this._setLength(0);
697 }
698 this._clearCancellationData();
699 };
700  
701 Promise.prototype._settledValue = function() {
702 var bitField = this._bitField;
703 if (((bitField & 33554432) !== 0)) {
704 return this._rejectionHandler0;
705 } else if (((bitField & 16777216) !== 0)) {
706 return this._fulfillmentHandler0;
707 }
708 };
709  
710 function deferResolve(v) {this.promise._resolveCallback(v);}
711 function deferReject(v) {this.promise._rejectCallback(v, false);}
712  
713 Promise.defer = Promise.pending = function() {
714 debug.deprecated("Promise.defer", "new Promise");
715 var promise = new Promise(INTERNAL);
716 return {
717 promise: promise,
718 resolve: deferResolve,
719 reject: deferReject
720 };
721 };
722  
723 util.notEnumerableProp(Promise,
724 "_makeSelfResolutionError",
725 makeSelfResolutionError);
726  
727 require("./method")(Promise, INTERNAL, tryConvertToPromise, apiRejection,
728 debug);
729 require("./bind")(Promise, INTERNAL, tryConvertToPromise, debug);
730 require("./cancel")(Promise, PromiseArray, apiRejection, debug);
731 require("./direct_resolve")(Promise);
732 require("./synchronous_inspection")(Promise);
733 require("./join")(
734 Promise, PromiseArray, tryConvertToPromise, INTERNAL, async, getDomain);
735 Promise.Promise = Promise;
736 Promise.version = "3.5.0";
737 require('./map.js')(Promise, PromiseArray, apiRejection, tryConvertToPromise, INTERNAL, debug);
738 require('./call_get.js')(Promise);
739 require('./using.js')(Promise, apiRejection, tryConvertToPromise, createContext, INTERNAL, debug);
740 require('./timers.js')(Promise, INTERNAL, debug);
741 require('./generators.js')(Promise, apiRejection, INTERNAL, tryConvertToPromise, Proxyable, debug);
742 require('./nodeify.js')(Promise);
743 require('./promisify.js')(Promise, INTERNAL);
744 require('./props.js')(Promise, PromiseArray, tryConvertToPromise, apiRejection);
745 require('./race.js')(Promise, INTERNAL, tryConvertToPromise, apiRejection);
746 require('./reduce.js')(Promise, PromiseArray, apiRejection, tryConvertToPromise, INTERNAL, debug);
747 require('./settle.js')(Promise, PromiseArray, debug);
748 require('./some.js')(Promise, PromiseArray, apiRejection);
749 require('./filter.js')(Promise, INTERNAL);
750 require('./each.js')(Promise, INTERNAL);
751 require('./any.js')(Promise);
752  
753 util.toFastProperties(Promise);
754 util.toFastProperties(Promise.prototype);
755 function fillTypes(value) {
756 var p = new Promise(INTERNAL);
757 p._fulfillmentHandler0 = value;
758 p._rejectionHandler0 = value;
759 p._promise0 = value;
760 p._receiver0 = value;
761 }
762 // Complete slack tracking, opt out of field-type tracking and
763 // stabilize map
764 fillTypes({a: 1});
765 fillTypes({b: 2});
766 fillTypes({c: 3});
767 fillTypes(1);
768 fillTypes(function(){});
769 fillTypes(undefined);
770 fillTypes(false);
771 fillTypes(new Promise(INTERNAL));
772 debug.setBounds(Async.firstLineError, util.lastLineError);
773 return Promise;
774  
775 };