browsed 0.2.5 → 0.2.6

Sign up to get free protection for your applications and to get access to all the features.
Files changed (172) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +2 -0
  3. data/Gemfile.lock +2 -2
  4. data/README.md +12 -17
  5. data/bin/browse +13 -10
  6. data/lib/browsed.rb +9 -2
  7. data/lib/browsed/browser.rb +82 -0
  8. data/lib/browsed/chrome.rb +21 -12
  9. data/lib/browsed/client.rb +48 -130
  10. data/lib/browsed/constants.rb +7 -1
  11. data/lib/browsed/errors.rb +1 -0
  12. data/lib/browsed/extensions/hash.rb +27 -0
  13. data/lib/browsed/firefox.rb +18 -17
  14. data/lib/browsed/manager.rb +5 -5
  15. data/lib/browsed/{poltergeist.rb → phantomjs.rb} +2 -2
  16. data/lib/browsed/proxies.rb +26 -0
  17. data/lib/browsed/{extensions → proxies}/chrome/proxy_authentication.rb +3 -3
  18. data/lib/browsed/proxies/proxy-chain-server/node_modules/.bin/portastic +1 -0
  19. data/lib/browsed/proxies/proxy-chain-server/node_modules/bluebird/LICENSE +21 -0
  20. data/lib/browsed/proxies/proxy-chain-server/node_modules/bluebird/README.md +57 -0
  21. data/lib/browsed/proxies/proxy-chain-server/node_modules/bluebird/changelog.md +1 -0
  22. data/lib/browsed/proxies/proxy-chain-server/node_modules/bluebird/js/browser/bluebird.core.js +3824 -0
  23. data/lib/browsed/proxies/proxy-chain-server/node_modules/bluebird/js/browser/bluebird.core.min.js +31 -0
  24. data/lib/browsed/proxies/proxy-chain-server/node_modules/bluebird/js/browser/bluebird.js +5666 -0
  25. data/lib/browsed/proxies/proxy-chain-server/node_modules/bluebird/js/browser/bluebird.min.js +31 -0
  26. data/lib/browsed/proxies/proxy-chain-server/node_modules/bluebird/js/release/any.js +21 -0
  27. data/lib/browsed/proxies/proxy-chain-server/node_modules/bluebird/js/release/assert.js +55 -0
  28. data/lib/browsed/proxies/proxy-chain-server/node_modules/bluebird/js/release/async.js +165 -0
  29. data/lib/browsed/proxies/proxy-chain-server/node_modules/bluebird/js/release/bind.js +67 -0
  30. data/lib/browsed/proxies/proxy-chain-server/node_modules/bluebird/js/release/bluebird.js +11 -0
  31. data/lib/browsed/proxies/proxy-chain-server/node_modules/bluebird/js/release/call_get.js +123 -0
  32. data/lib/browsed/proxies/proxy-chain-server/node_modules/bluebird/js/release/cancel.js +129 -0
  33. data/lib/browsed/proxies/proxy-chain-server/node_modules/bluebird/js/release/catch_filter.js +42 -0
  34. data/lib/browsed/proxies/proxy-chain-server/node_modules/bluebird/js/release/context.js +69 -0
  35. data/lib/browsed/proxies/proxy-chain-server/node_modules/bluebird/js/release/debuggability.js +934 -0
  36. data/lib/browsed/proxies/proxy-chain-server/node_modules/bluebird/js/release/direct_resolve.js +46 -0
  37. data/lib/browsed/proxies/proxy-chain-server/node_modules/bluebird/js/release/each.js +30 -0
  38. data/lib/browsed/proxies/proxy-chain-server/node_modules/bluebird/js/release/errors.js +116 -0
  39. data/lib/browsed/proxies/proxy-chain-server/node_modules/bluebird/js/release/es5.js +80 -0
  40. data/lib/browsed/proxies/proxy-chain-server/node_modules/bluebird/js/release/filter.js +12 -0
  41. data/lib/browsed/proxies/proxy-chain-server/node_modules/bluebird/js/release/finally.js +146 -0
  42. data/lib/browsed/proxies/proxy-chain-server/node_modules/bluebird/js/release/generators.js +223 -0
  43. data/lib/browsed/proxies/proxy-chain-server/node_modules/bluebird/js/release/join.js +168 -0
  44. data/lib/browsed/proxies/proxy-chain-server/node_modules/bluebird/js/release/map.js +168 -0
  45. data/lib/browsed/proxies/proxy-chain-server/node_modules/bluebird/js/release/method.js +55 -0
  46. data/lib/browsed/proxies/proxy-chain-server/node_modules/bluebird/js/release/nodeback.js +51 -0
  47. data/lib/browsed/proxies/proxy-chain-server/node_modules/bluebird/js/release/nodeify.js +58 -0
  48. data/lib/browsed/proxies/proxy-chain-server/node_modules/bluebird/js/release/promise.js +789 -0
  49. data/lib/browsed/proxies/proxy-chain-server/node_modules/bluebird/js/release/promise_array.js +185 -0
  50. data/lib/browsed/proxies/proxy-chain-server/node_modules/bluebird/js/release/promisify.js +314 -0
  51. data/lib/browsed/proxies/proxy-chain-server/node_modules/bluebird/js/release/props.js +118 -0
  52. data/lib/browsed/proxies/proxy-chain-server/node_modules/bluebird/js/release/queue.js +73 -0
  53. data/lib/browsed/proxies/proxy-chain-server/node_modules/bluebird/js/release/race.js +49 -0
  54. data/lib/browsed/proxies/proxy-chain-server/node_modules/bluebird/js/release/reduce.js +172 -0
  55. data/lib/browsed/proxies/proxy-chain-server/node_modules/bluebird/js/release/schedule.js +62 -0
  56. data/lib/browsed/proxies/proxy-chain-server/node_modules/bluebird/js/release/settle.js +43 -0
  57. data/lib/browsed/proxies/proxy-chain-server/node_modules/bluebird/js/release/some.js +148 -0
  58. data/lib/browsed/proxies/proxy-chain-server/node_modules/bluebird/js/release/synchronous_inspection.js +103 -0
  59. data/lib/browsed/proxies/proxy-chain-server/node_modules/bluebird/js/release/thenables.js +86 -0
  60. data/lib/browsed/proxies/proxy-chain-server/node_modules/bluebird/js/release/timers.js +93 -0
  61. data/lib/browsed/proxies/proxy-chain-server/node_modules/bluebird/js/release/using.js +226 -0
  62. data/lib/browsed/proxies/proxy-chain-server/node_modules/bluebird/js/release/util.js +389 -0
  63. data/lib/browsed/proxies/proxy-chain-server/node_modules/bluebird/package.json +102 -0
  64. data/lib/browsed/proxies/proxy-chain-server/node_modules/commander/CHANGELOG.md +408 -0
  65. data/lib/browsed/proxies/proxy-chain-server/node_modules/commander/LICENSE +22 -0
  66. data/lib/browsed/proxies/proxy-chain-server/node_modules/commander/Readme.md +428 -0
  67. data/lib/browsed/proxies/proxy-chain-server/node_modules/commander/index.js +1224 -0
  68. data/lib/browsed/proxies/proxy-chain-server/node_modules/commander/package.json +70 -0
  69. data/lib/browsed/proxies/proxy-chain-server/node_modules/commander/typings/index.d.ts +310 -0
  70. data/lib/browsed/proxies/proxy-chain-server/node_modules/debug/.coveralls.yml +1 -0
  71. data/lib/browsed/proxies/proxy-chain-server/node_modules/debug/.eslintrc +11 -0
  72. data/lib/browsed/proxies/proxy-chain-server/node_modules/debug/.npmignore +9 -0
  73. data/lib/browsed/proxies/proxy-chain-server/node_modules/debug/.travis.yml +14 -0
  74. data/lib/browsed/proxies/proxy-chain-server/node_modules/debug/CHANGELOG.md +362 -0
  75. data/lib/browsed/proxies/proxy-chain-server/node_modules/debug/LICENSE +19 -0
  76. data/lib/browsed/proxies/proxy-chain-server/node_modules/debug/Makefile +50 -0
  77. data/lib/browsed/proxies/proxy-chain-server/node_modules/debug/README.md +312 -0
  78. data/lib/browsed/proxies/proxy-chain-server/node_modules/debug/component.json +19 -0
  79. data/lib/browsed/proxies/proxy-chain-server/node_modules/debug/karma.conf.js +70 -0
  80. data/lib/browsed/proxies/proxy-chain-server/node_modules/debug/node.js +1 -0
  81. data/lib/browsed/proxies/proxy-chain-server/node_modules/debug/package.json +88 -0
  82. data/lib/browsed/proxies/proxy-chain-server/node_modules/debug/src/browser.js +185 -0
  83. data/lib/browsed/proxies/proxy-chain-server/node_modules/debug/src/debug.js +202 -0
  84. data/lib/browsed/proxies/proxy-chain-server/node_modules/debug/src/index.js +10 -0
  85. data/lib/browsed/proxies/proxy-chain-server/node_modules/debug/src/inspector-log.js +15 -0
  86. data/lib/browsed/proxies/proxy-chain-server/node_modules/debug/src/node.js +248 -0
  87. data/lib/browsed/proxies/proxy-chain-server/node_modules/ms/index.js +152 -0
  88. data/lib/browsed/proxies/proxy-chain-server/node_modules/ms/license.md +21 -0
  89. data/lib/browsed/proxies/proxy-chain-server/node_modules/ms/package.json +69 -0
  90. data/lib/browsed/proxies/proxy-chain-server/node_modules/ms/readme.md +51 -0
  91. data/lib/browsed/proxies/proxy-chain-server/node_modules/portastic/LICENSE +13 -0
  92. data/lib/browsed/proxies/proxy-chain-server/node_modules/portastic/README.md +148 -0
  93. data/lib/browsed/proxies/proxy-chain-server/node_modules/portastic/bin/portastic +65 -0
  94. data/lib/browsed/proxies/proxy-chain-server/node_modules/portastic/history.md +7 -0
  95. data/lib/browsed/proxies/proxy-chain-server/node_modules/portastic/index.js +4 -0
  96. data/lib/browsed/proxies/proxy-chain-server/node_modules/portastic/lib/monitor.js +59 -0
  97. data/lib/browsed/proxies/proxy-chain-server/node_modules/portastic/lib/portastic.js +167 -0
  98. data/lib/browsed/proxies/proxy-chain-server/node_modules/portastic/node_modules/bluebird/LICENSE +21 -0
  99. data/lib/browsed/proxies/proxy-chain-server/node_modules/portastic/node_modules/bluebird/README.md +677 -0
  100. data/lib/browsed/proxies/proxy-chain-server/node_modules/portastic/node_modules/bluebird/changelog.md +1730 -0
  101. data/lib/browsed/proxies/proxy-chain-server/node_modules/portastic/node_modules/bluebird/js/browser/bluebird.js +4892 -0
  102. data/lib/browsed/proxies/proxy-chain-server/node_modules/portastic/node_modules/bluebird/js/browser/bluebird.min.js +31 -0
  103. data/lib/browsed/proxies/proxy-chain-server/node_modules/portastic/node_modules/bluebird/js/main/any.js +21 -0
  104. data/lib/browsed/proxies/proxy-chain-server/node_modules/portastic/node_modules/bluebird/js/main/assert.js +55 -0
  105. data/lib/browsed/proxies/proxy-chain-server/node_modules/portastic/node_modules/bluebird/js/main/async.js +150 -0
  106. data/lib/browsed/proxies/proxy-chain-server/node_modules/portastic/node_modules/bluebird/js/main/bind.js +72 -0
  107. data/lib/browsed/proxies/proxy-chain-server/node_modules/portastic/node_modules/bluebird/js/main/bluebird.js +11 -0
  108. data/lib/browsed/proxies/proxy-chain-server/node_modules/portastic/node_modules/bluebird/js/main/call_get.js +123 -0
  109. data/lib/browsed/proxies/proxy-chain-server/node_modules/portastic/node_modules/bluebird/js/main/cancel.js +48 -0
  110. data/lib/browsed/proxies/proxy-chain-server/node_modules/portastic/node_modules/bluebird/js/main/captured_trace.js +493 -0
  111. data/lib/browsed/proxies/proxy-chain-server/node_modules/portastic/node_modules/bluebird/js/main/catch_filter.js +66 -0
  112. data/lib/browsed/proxies/proxy-chain-server/node_modules/portastic/node_modules/bluebird/js/main/context.js +38 -0
  113. data/lib/browsed/proxies/proxy-chain-server/node_modules/portastic/node_modules/bluebird/js/main/debuggability.js +162 -0
  114. data/lib/browsed/proxies/proxy-chain-server/node_modules/portastic/node_modules/bluebird/js/main/direct_resolve.js +63 -0
  115. data/lib/browsed/proxies/proxy-chain-server/node_modules/portastic/node_modules/bluebird/js/main/each.js +12 -0
  116. data/lib/browsed/proxies/proxy-chain-server/node_modules/portastic/node_modules/bluebird/js/main/errors.js +111 -0
  117. data/lib/browsed/proxies/proxy-chain-server/node_modules/portastic/node_modules/bluebird/js/main/es5.js +80 -0
  118. data/lib/browsed/proxies/proxy-chain-server/node_modules/portastic/node_modules/bluebird/js/main/filter.js +12 -0
  119. data/lib/browsed/proxies/proxy-chain-server/node_modules/portastic/node_modules/bluebird/js/main/finally.js +98 -0
  120. data/lib/browsed/proxies/proxy-chain-server/node_modules/portastic/node_modules/bluebird/js/main/generators.js +136 -0
  121. data/lib/browsed/proxies/proxy-chain-server/node_modules/portastic/node_modules/bluebird/js/main/join.js +107 -0
  122. data/lib/browsed/proxies/proxy-chain-server/node_modules/portastic/node_modules/bluebird/js/main/map.js +133 -0
  123. data/lib/browsed/proxies/proxy-chain-server/node_modules/portastic/node_modules/bluebird/js/main/method.js +44 -0
  124. data/lib/browsed/proxies/proxy-chain-server/node_modules/portastic/node_modules/bluebird/js/main/nodeify.js +59 -0
  125. data/lib/browsed/proxies/proxy-chain-server/node_modules/portastic/node_modules/bluebird/js/main/progress.js +76 -0
  126. data/lib/browsed/proxies/proxy-chain-server/node_modules/portastic/node_modules/bluebird/js/main/promise.js +759 -0
  127. data/lib/browsed/proxies/proxy-chain-server/node_modules/portastic/node_modules/bluebird/js/main/promise_array.js +142 -0
  128. data/lib/browsed/proxies/proxy-chain-server/node_modules/portastic/node_modules/bluebird/js/main/promise_resolver.js +123 -0
  129. data/lib/browsed/proxies/proxy-chain-server/node_modules/portastic/node_modules/bluebird/js/main/promisify.js +307 -0
  130. data/lib/browsed/proxies/proxy-chain-server/node_modules/portastic/node_modules/bluebird/js/main/props.js +79 -0
  131. data/lib/browsed/proxies/proxy-chain-server/node_modules/portastic/node_modules/bluebird/js/main/queue.js +90 -0
  132. data/lib/browsed/proxies/proxy-chain-server/node_modules/portastic/node_modules/bluebird/js/main/race.js +47 -0
  133. data/lib/browsed/proxies/proxy-chain-server/node_modules/portastic/node_modules/bluebird/js/main/reduce.js +148 -0
  134. data/lib/browsed/proxies/proxy-chain-server/node_modules/portastic/node_modules/bluebird/js/main/schedule.js +35 -0
  135. data/lib/browsed/proxies/proxy-chain-server/node_modules/portastic/node_modules/bluebird/js/main/settle.js +40 -0
  136. data/lib/browsed/proxies/proxy-chain-server/node_modules/portastic/node_modules/bluebird/js/main/some.js +125 -0
  137. data/lib/browsed/proxies/proxy-chain-server/node_modules/portastic/node_modules/bluebird/js/main/synchronous_inspection.js +94 -0
  138. data/lib/browsed/proxies/proxy-chain-server/node_modules/portastic/node_modules/bluebird/js/main/thenables.js +84 -0
  139. data/lib/browsed/proxies/proxy-chain-server/node_modules/portastic/node_modules/bluebird/js/main/timers.js +64 -0
  140. data/lib/browsed/proxies/proxy-chain-server/node_modules/portastic/node_modules/bluebird/js/main/using.js +213 -0
  141. data/lib/browsed/proxies/proxy-chain-server/node_modules/portastic/node_modules/bluebird/js/main/util.js +321 -0
  142. data/lib/browsed/proxies/proxy-chain-server/node_modules/portastic/node_modules/bluebird/package.json +103 -0
  143. data/lib/browsed/proxies/proxy-chain-server/node_modules/portastic/package.json +69 -0
  144. data/lib/browsed/proxies/proxy-chain-server/node_modules/proxy-chain/CHANGELOG.md +109 -0
  145. data/lib/browsed/proxies/proxy-chain-server/node_modules/proxy-chain/LICENSE +201 -0
  146. data/lib/browsed/proxies/proxy-chain-server/node_modules/proxy-chain/README.md +278 -0
  147. data/lib/browsed/proxies/proxy-chain-server/node_modules/proxy-chain/build/anonymize_proxy.js +100 -0
  148. data/lib/browsed/proxies/proxy-chain-server/node_modules/proxy-chain/build/handler_base.js +319 -0
  149. data/lib/browsed/proxies/proxy-chain-server/node_modules/proxy-chain/build/handler_custom_response.js +96 -0
  150. data/lib/browsed/proxies/proxy-chain-server/node_modules/proxy-chain/build/handler_forward.js +173 -0
  151. data/lib/browsed/proxies/proxy-chain-server/node_modules/proxy-chain/build/handler_tunnel_chain.js +132 -0
  152. data/lib/browsed/proxies/proxy-chain-server/node_modules/proxy-chain/build/handler_tunnel_direct.js +89 -0
  153. data/lib/browsed/proxies/proxy-chain-server/node_modules/proxy-chain/build/handler_tunnel_tcp_chain.js +271 -0
  154. data/lib/browsed/proxies/proxy-chain-server/node_modules/proxy-chain/build/index.js +26 -0
  155. data/lib/browsed/proxies/proxy-chain-server/node_modules/proxy-chain/build/run_locally.js +66 -0
  156. data/lib/browsed/proxies/proxy-chain-server/node_modules/proxy-chain/build/server.js +595 -0
  157. data/lib/browsed/proxies/proxy-chain-server/node_modules/proxy-chain/build/tcp_tunnel.js +138 -0
  158. data/lib/browsed/proxies/proxy-chain-server/node_modules/proxy-chain/build/testing_tcp_service.js +37 -0
  159. data/lib/browsed/proxies/proxy-chain-server/node_modules/proxy-chain/build/tools.js +220 -0
  160. data/lib/browsed/proxies/proxy-chain-server/node_modules/proxy-chain/package.json +104 -0
  161. data/lib/browsed/proxies/proxy-chain-server/node_modules/underscore/LICENSE +23 -0
  162. data/lib/browsed/proxies/proxy-chain-server/node_modules/underscore/README.md +28 -0
  163. data/lib/browsed/proxies/proxy-chain-server/node_modules/underscore/package.json +81 -0
  164. data/lib/browsed/proxies/proxy-chain-server/node_modules/underscore/underscore-min.js +5 -0
  165. data/lib/browsed/proxies/proxy-chain-server/node_modules/underscore/underscore-min.js.map +1 -0
  166. data/lib/browsed/proxies/proxy-chain-server/node_modules/underscore/underscore.js +1692 -0
  167. data/lib/browsed/proxies/proxy-chain-server/package-lock.json +63 -0
  168. data/lib/browsed/proxies/proxy-chain-server/package.json +15 -0
  169. data/lib/browsed/proxies/proxy-chain-server/server.js +25 -0
  170. data/lib/browsed/proxies/proxy_chain.rb +36 -0
  171. data/lib/browsed/version.rb +1 -1
  172. metadata +160 -4
@@ -0,0 +1,44 @@
1
+ "use strict";
2
+ module.exports =
3
+ function(Promise, INTERNAL, tryConvertToPromise, apiRejection) {
4
+ var util = require("./util.js");
5
+ var tryCatch = util.tryCatch;
6
+
7
+ Promise.method = function (fn) {
8
+ if (typeof fn !== "function") {
9
+ throw new Promise.TypeError("fn must be a function\u000a\u000a See http://goo.gl/916lJJ\u000a");
10
+ }
11
+ return function () {
12
+ var ret = new Promise(INTERNAL);
13
+ ret._captureStackTrace();
14
+ ret._pushContext();
15
+ var value = tryCatch(fn).apply(this, arguments);
16
+ ret._popContext();
17
+ ret._resolveFromSyncValue(value);
18
+ return ret;
19
+ };
20
+ };
21
+
22
+ Promise.attempt = Promise["try"] = function (fn, args, ctx) {
23
+ if (typeof fn !== "function") {
24
+ return apiRejection("fn must be a function\u000a\u000a See http://goo.gl/916lJJ\u000a");
25
+ }
26
+ var ret = new Promise(INTERNAL);
27
+ ret._captureStackTrace();
28
+ ret._pushContext();
29
+ var value = util.isArray(args)
30
+ ? tryCatch(fn).apply(ctx, args)
31
+ : tryCatch(fn).call(ctx, args);
32
+ ret._popContext();
33
+ ret._resolveFromSyncValue(value);
34
+ return ret;
35
+ };
36
+
37
+ Promise.prototype._resolveFromSyncValue = function (value) {
38
+ if (value === util.errorObj) {
39
+ this._rejectCallback(value.e, false, true);
40
+ } else {
41
+ this._resolveCallback(value, true);
42
+ }
43
+ };
44
+ };
@@ -0,0 +1,59 @@
1
+ "use strict";
2
+ module.exports = function(Promise) {
3
+ var util = require("./util.js");
4
+ var async = require("./async.js");
5
+ var tryCatch = util.tryCatch;
6
+ var errorObj = util.errorObj;
7
+
8
+ function spreadAdapter(val, nodeback) {
9
+ var promise = this;
10
+ if (!util.isArray(val)) return successAdapter.call(promise, val, nodeback);
11
+ var ret =
12
+ tryCatch(nodeback).apply(promise._boundValue(), [null].concat(val));
13
+ if (ret === errorObj) {
14
+ async.throwLater(ret.e);
15
+ }
16
+ }
17
+
18
+ function successAdapter(val, nodeback) {
19
+ var promise = this;
20
+ var receiver = promise._boundValue();
21
+ var ret = val === undefined
22
+ ? tryCatch(nodeback).call(receiver, null)
23
+ : tryCatch(nodeback).call(receiver, null, val);
24
+ if (ret === errorObj) {
25
+ async.throwLater(ret.e);
26
+ }
27
+ }
28
+ function errorAdapter(reason, nodeback) {
29
+ var promise = this;
30
+ if (!reason) {
31
+ var target = promise._target();
32
+ var newReason = target._getCarriedStackTrace();
33
+ newReason.cause = reason;
34
+ reason = newReason;
35
+ }
36
+ var ret = tryCatch(nodeback).call(promise._boundValue(), reason);
37
+ if (ret === errorObj) {
38
+ async.throwLater(ret.e);
39
+ }
40
+ }
41
+
42
+ Promise.prototype.asCallback =
43
+ Promise.prototype.nodeify = function (nodeback, options) {
44
+ if (typeof nodeback == "function") {
45
+ var adapter = successAdapter;
46
+ if (options !== undefined && Object(options).spread) {
47
+ adapter = spreadAdapter;
48
+ }
49
+ this._then(
50
+ adapter,
51
+ errorAdapter,
52
+ undefined,
53
+ this,
54
+ nodeback
55
+ );
56
+ }
57
+ return this;
58
+ };
59
+ };
@@ -0,0 +1,76 @@
1
+ "use strict";
2
+ module.exports = function(Promise, PromiseArray) {
3
+ var util = require("./util.js");
4
+ var async = require("./async.js");
5
+ var tryCatch = util.tryCatch;
6
+ var errorObj = util.errorObj;
7
+
8
+ Promise.prototype.progressed = function (handler) {
9
+ return this._then(undefined, undefined, handler, undefined, undefined);
10
+ };
11
+
12
+ Promise.prototype._progress = function (progressValue) {
13
+ if (this._isFollowingOrFulfilledOrRejected()) return;
14
+ this._target()._progressUnchecked(progressValue);
15
+
16
+ };
17
+
18
+ Promise.prototype._progressHandlerAt = function (index) {
19
+ return index === 0
20
+ ? this._progressHandler0
21
+ : this[(index << 2) + index - 5 + 2];
22
+ };
23
+
24
+ Promise.prototype._doProgressWith = function (progression) {
25
+ var progressValue = progression.value;
26
+ var handler = progression.handler;
27
+ var promise = progression.promise;
28
+ var receiver = progression.receiver;
29
+
30
+ var ret = tryCatch(handler).call(receiver, progressValue);
31
+ if (ret === errorObj) {
32
+ if (ret.e != null &&
33
+ ret.e.name !== "StopProgressPropagation") {
34
+ var trace = util.canAttachTrace(ret.e)
35
+ ? ret.e : new Error(util.toString(ret.e));
36
+ promise._attachExtraTrace(trace);
37
+ promise._progress(ret.e);
38
+ }
39
+ } else if (ret instanceof Promise) {
40
+ ret._then(promise._progress, null, null, promise, undefined);
41
+ } else {
42
+ promise._progress(ret);
43
+ }
44
+ };
45
+
46
+
47
+ Promise.prototype._progressUnchecked = function (progressValue) {
48
+ var len = this._length();
49
+ var progress = this._progress;
50
+ for (var i = 0; i < len; i++) {
51
+ var handler = this._progressHandlerAt(i);
52
+ var promise = this._promiseAt(i);
53
+ if (!(promise instanceof Promise)) {
54
+ var receiver = this._receiverAt(i);
55
+ if (typeof handler === "function") {
56
+ handler.call(receiver, progressValue, promise);
57
+ } else if (receiver instanceof PromiseArray &&
58
+ !receiver._isResolved()) {
59
+ receiver._promiseProgressed(progressValue, promise);
60
+ }
61
+ continue;
62
+ }
63
+
64
+ if (typeof handler === "function") {
65
+ async.invoke(this._doProgressWith, this, {
66
+ handler: handler,
67
+ promise: promise,
68
+ receiver: this._receiverAt(i),
69
+ value: progressValue
70
+ });
71
+ } else {
72
+ async.invoke(progress, promise, progressValue);
73
+ }
74
+ }
75
+ };
76
+ };
@@ -0,0 +1,759 @@
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/LhFpo0\u000a");
5
+ };
6
+ var reflect = function() {
7
+ return new Promise.PromiseInspection(this._target());
8
+ };
9
+ var apiRejection = function(msg) {
10
+ return Promise.reject(new TypeError(msg));
11
+ };
12
+
13
+ var util = require("./util.js");
14
+
15
+ var getDomain;
16
+ if (util.isNode) {
17
+ getDomain = function() {
18
+ var ret = process.domain;
19
+ if (ret === undefined) ret = null;
20
+ return ret;
21
+ };
22
+ } else {
23
+ getDomain = function() {
24
+ return null;
25
+ };
26
+ }
27
+ util.notEnumerableProp(Promise, "_getDomain", getDomain);
28
+
29
+ var UNDEFINED_BINDING = {};
30
+ var async = require("./async.js");
31
+ var errors = require("./errors.js");
32
+ var TypeError = Promise.TypeError = errors.TypeError;
33
+ Promise.RangeError = errors.RangeError;
34
+ Promise.CancellationError = errors.CancellationError;
35
+ Promise.TimeoutError = errors.TimeoutError;
36
+ Promise.OperationalError = errors.OperationalError;
37
+ Promise.RejectionError = errors.OperationalError;
38
+ Promise.AggregateError = errors.AggregateError;
39
+ var INTERNAL = function(){};
40
+ var APPLY = {};
41
+ var NEXT_FILTER = {e: null};
42
+ var tryConvertToPromise = require("./thenables.js")(Promise, INTERNAL);
43
+ var PromiseArray =
44
+ require("./promise_array.js")(Promise, INTERNAL,
45
+ tryConvertToPromise, apiRejection);
46
+ var CapturedTrace = require("./captured_trace.js")();
47
+ var isDebugging = require("./debuggability.js")(Promise, CapturedTrace);
48
+ /*jshint unused:false*/
49
+ var createContext =
50
+ require("./context.js")(Promise, CapturedTrace, isDebugging);
51
+ var CatchFilter = require("./catch_filter.js")(NEXT_FILTER);
52
+ var PromiseResolver = require("./promise_resolver.js");
53
+ var nodebackForPromise = PromiseResolver._nodebackForPromise;
54
+ var errorObj = util.errorObj;
55
+ var tryCatch = util.tryCatch;
56
+
57
+ function Promise(resolver) {
58
+ if (typeof resolver !== "function") {
59
+ throw new TypeError("the promise constructor requires a resolver function\u000a\u000a See http://goo.gl/EC22Yn\u000a");
60
+ }
61
+ if (this.constructor !== Promise) {
62
+ throw new TypeError("the promise constructor cannot be invoked directly\u000a\u000a See http://goo.gl/KsIlge\u000a");
63
+ }
64
+ this._bitField = 0;
65
+ this._fulfillmentHandler0 = undefined;
66
+ this._rejectionHandler0 = undefined;
67
+ this._progressHandler0 = undefined;
68
+ this._promise0 = undefined;
69
+ this._receiver0 = undefined;
70
+ this._settledValue = undefined;
71
+ if (resolver !== INTERNAL) this._resolveFromResolver(resolver);
72
+ }
73
+
74
+ Promise.prototype.toString = function () {
75
+ return "[object Promise]";
76
+ };
77
+
78
+ Promise.prototype.caught = Promise.prototype["catch"] = function (fn) {
79
+ var len = arguments.length;
80
+ if (len > 1) {
81
+ var catchInstances = new Array(len - 1),
82
+ j = 0, i;
83
+ for (i = 0; i < len - 1; ++i) {
84
+ var item = arguments[i];
85
+ if (typeof item === "function") {
86
+ catchInstances[j++] = item;
87
+ } else {
88
+ return Promise.reject(
89
+ new TypeError("Catch filter must inherit from Error or be a simple predicate function\u000a\u000a See http://goo.gl/o84o68\u000a"));
90
+ }
91
+ }
92
+ catchInstances.length = j;
93
+ fn = arguments[i];
94
+ var catchFilter = new CatchFilter(catchInstances, fn, this);
95
+ return this._then(undefined, catchFilter.doFilter, undefined,
96
+ catchFilter, undefined);
97
+ }
98
+ return this._then(undefined, fn, undefined, undefined, undefined);
99
+ };
100
+
101
+ Promise.prototype.reflect = function () {
102
+ return this._then(reflect, reflect, undefined, this, undefined);
103
+ };
104
+
105
+ Promise.prototype.then = function (didFulfill, didReject, didProgress) {
106
+ if (isDebugging() && arguments.length > 0 &&
107
+ typeof didFulfill !== "function" &&
108
+ typeof didReject !== "function") {
109
+ var msg = ".then() only accepts functions but was passed: " +
110
+ util.classString(didFulfill);
111
+ if (arguments.length > 1) {
112
+ msg += ", " + util.classString(didReject);
113
+ }
114
+ this._warn(msg);
115
+ }
116
+ return this._then(didFulfill, didReject, didProgress,
117
+ undefined, undefined);
118
+ };
119
+
120
+ Promise.prototype.done = function (didFulfill, didReject, didProgress) {
121
+ var promise = this._then(didFulfill, didReject, didProgress,
122
+ undefined, undefined);
123
+ promise._setIsFinal();
124
+ };
125
+
126
+ Promise.prototype.spread = function (didFulfill, didReject) {
127
+ return this.all()._then(didFulfill, didReject, undefined, APPLY, undefined);
128
+ };
129
+
130
+ Promise.prototype.isCancellable = function () {
131
+ return !this.isResolved() &&
132
+ this._cancellable();
133
+ };
134
+
135
+ Promise.prototype.toJSON = function () {
136
+ var ret = {
137
+ isFulfilled: false,
138
+ isRejected: false,
139
+ fulfillmentValue: undefined,
140
+ rejectionReason: undefined
141
+ };
142
+ if (this.isFulfilled()) {
143
+ ret.fulfillmentValue = this.value();
144
+ ret.isFulfilled = true;
145
+ } else if (this.isRejected()) {
146
+ ret.rejectionReason = this.reason();
147
+ ret.isRejected = true;
148
+ }
149
+ return ret;
150
+ };
151
+
152
+ Promise.prototype.all = function () {
153
+ return new PromiseArray(this).promise();
154
+ };
155
+
156
+ Promise.prototype.error = function (fn) {
157
+ return this.caught(util.originatesFromRejection, fn);
158
+ };
159
+
160
+ Promise.getNewLibraryCopy = module.exports;
161
+
162
+ Promise.is = function (val) {
163
+ return val instanceof Promise;
164
+ };
165
+
166
+ Promise.fromNode = function(fn) {
167
+ var ret = new Promise(INTERNAL);
168
+ var result = tryCatch(fn)(nodebackForPromise(ret));
169
+ if (result === errorObj) {
170
+ ret._rejectCallback(result.e, true, true);
171
+ }
172
+ return ret;
173
+ };
174
+
175
+ Promise.all = function (promises) {
176
+ return new PromiseArray(promises).promise();
177
+ };
178
+
179
+ Promise.defer = Promise.pending = function () {
180
+ var promise = new Promise(INTERNAL);
181
+ return new PromiseResolver(promise);
182
+ };
183
+
184
+ Promise.cast = function (obj) {
185
+ var ret = tryConvertToPromise(obj);
186
+ if (!(ret instanceof Promise)) {
187
+ var val = ret;
188
+ ret = new Promise(INTERNAL);
189
+ ret._fulfillUnchecked(val);
190
+ }
191
+ return ret;
192
+ };
193
+
194
+ Promise.resolve = Promise.fulfilled = Promise.cast;
195
+
196
+ Promise.reject = Promise.rejected = function (reason) {
197
+ var ret = new Promise(INTERNAL);
198
+ ret._captureStackTrace();
199
+ ret._rejectCallback(reason, true);
200
+ return ret;
201
+ };
202
+
203
+ Promise.setScheduler = function(fn) {
204
+ if (typeof fn !== "function") throw new TypeError("fn must be a function\u000a\u000a See http://goo.gl/916lJJ\u000a");
205
+ var prev = async._schedule;
206
+ async._schedule = fn;
207
+ return prev;
208
+ };
209
+
210
+ Promise.prototype._then = function (
211
+ didFulfill,
212
+ didReject,
213
+ didProgress,
214
+ receiver,
215
+ internalData
216
+ ) {
217
+ var haveInternalData = internalData !== undefined;
218
+ var ret = haveInternalData ? internalData : new Promise(INTERNAL);
219
+
220
+ if (!haveInternalData) {
221
+ ret._propagateFrom(this, 4 | 1);
222
+ ret._captureStackTrace();
223
+ }
224
+
225
+ var target = this._target();
226
+ if (target !== this) {
227
+ if (receiver === undefined) receiver = this._boundTo;
228
+ if (!haveInternalData) ret._setIsMigrated();
229
+ }
230
+
231
+ var callbackIndex = target._addCallbacks(didFulfill,
232
+ didReject,
233
+ didProgress,
234
+ ret,
235
+ receiver,
236
+ getDomain());
237
+
238
+ if (target._isResolved() && !target._isSettlePromisesQueued()) {
239
+ async.invoke(
240
+ target._settlePromiseAtPostResolution, target, callbackIndex);
241
+ }
242
+
243
+ return ret;
244
+ };
245
+
246
+ Promise.prototype._settlePromiseAtPostResolution = function (index) {
247
+ if (this._isRejectionUnhandled()) this._unsetRejectionIsUnhandled();
248
+ this._settlePromiseAt(index);
249
+ };
250
+
251
+ Promise.prototype._length = function () {
252
+ return this._bitField & 131071;
253
+ };
254
+
255
+ Promise.prototype._isFollowingOrFulfilledOrRejected = function () {
256
+ return (this._bitField & 939524096) > 0;
257
+ };
258
+
259
+ Promise.prototype._isFollowing = function () {
260
+ return (this._bitField & 536870912) === 536870912;
261
+ };
262
+
263
+ Promise.prototype._setLength = function (len) {
264
+ this._bitField = (this._bitField & -131072) |
265
+ (len & 131071);
266
+ };
267
+
268
+ Promise.prototype._setFulfilled = function () {
269
+ this._bitField = this._bitField | 268435456;
270
+ };
271
+
272
+ Promise.prototype._setRejected = function () {
273
+ this._bitField = this._bitField | 134217728;
274
+ };
275
+
276
+ Promise.prototype._setFollowing = function () {
277
+ this._bitField = this._bitField | 536870912;
278
+ };
279
+
280
+ Promise.prototype._setIsFinal = function () {
281
+ this._bitField = this._bitField | 33554432;
282
+ };
283
+
284
+ Promise.prototype._isFinal = function () {
285
+ return (this._bitField & 33554432) > 0;
286
+ };
287
+
288
+ Promise.prototype._cancellable = function () {
289
+ return (this._bitField & 67108864) > 0;
290
+ };
291
+
292
+ Promise.prototype._setCancellable = function () {
293
+ this._bitField = this._bitField | 67108864;
294
+ };
295
+
296
+ Promise.prototype._unsetCancellable = function () {
297
+ this._bitField = this._bitField & (~67108864);
298
+ };
299
+
300
+ Promise.prototype._setIsMigrated = function () {
301
+ this._bitField = this._bitField | 4194304;
302
+ };
303
+
304
+ Promise.prototype._unsetIsMigrated = function () {
305
+ this._bitField = this._bitField & (~4194304);
306
+ };
307
+
308
+ Promise.prototype._isMigrated = function () {
309
+ return (this._bitField & 4194304) > 0;
310
+ };
311
+
312
+ Promise.prototype._receiverAt = function (index) {
313
+ var ret = index === 0
314
+ ? this._receiver0
315
+ : this[
316
+ index * 5 - 5 + 4];
317
+ if (ret === UNDEFINED_BINDING) {
318
+ return undefined;
319
+ } else if (ret === undefined && this._isBound()) {
320
+ return this._boundValue();
321
+ }
322
+ return ret;
323
+ };
324
+
325
+ Promise.prototype._promiseAt = function (index) {
326
+ return index === 0
327
+ ? this._promise0
328
+ : this[index * 5 - 5 + 3];
329
+ };
330
+
331
+ Promise.prototype._fulfillmentHandlerAt = function (index) {
332
+ return index === 0
333
+ ? this._fulfillmentHandler0
334
+ : this[index * 5 - 5 + 0];
335
+ };
336
+
337
+ Promise.prototype._rejectionHandlerAt = function (index) {
338
+ return index === 0
339
+ ? this._rejectionHandler0
340
+ : this[index * 5 - 5 + 1];
341
+ };
342
+
343
+ Promise.prototype._boundValue = function() {
344
+ var ret = this._boundTo;
345
+ if (ret !== undefined) {
346
+ if (ret instanceof Promise) {
347
+ if (ret.isFulfilled()) {
348
+ return ret.value();
349
+ } else {
350
+ return undefined;
351
+ }
352
+ }
353
+ }
354
+ return ret;
355
+ };
356
+
357
+ Promise.prototype._migrateCallbacks = function (follower, index) {
358
+ var fulfill = follower._fulfillmentHandlerAt(index);
359
+ var reject = follower._rejectionHandlerAt(index);
360
+ var progress = follower._progressHandlerAt(index);
361
+ var promise = follower._promiseAt(index);
362
+ var receiver = follower._receiverAt(index);
363
+ if (promise instanceof Promise) promise._setIsMigrated();
364
+ if (receiver === undefined) receiver = UNDEFINED_BINDING;
365
+ this._addCallbacks(fulfill, reject, progress, promise, receiver, null);
366
+ };
367
+
368
+ Promise.prototype._addCallbacks = function (
369
+ fulfill,
370
+ reject,
371
+ progress,
372
+ promise,
373
+ receiver,
374
+ domain
375
+ ) {
376
+ var index = this._length();
377
+
378
+ if (index >= 131071 - 5) {
379
+ index = 0;
380
+ this._setLength(0);
381
+ }
382
+
383
+ if (index === 0) {
384
+ this._promise0 = promise;
385
+ if (receiver !== undefined) this._receiver0 = receiver;
386
+ if (typeof fulfill === "function" && !this._isCarryingStackTrace()) {
387
+ this._fulfillmentHandler0 =
388
+ domain === null ? fulfill : domain.bind(fulfill);
389
+ }
390
+ if (typeof reject === "function") {
391
+ this._rejectionHandler0 =
392
+ domain === null ? reject : domain.bind(reject);
393
+ }
394
+ if (typeof progress === "function") {
395
+ this._progressHandler0 =
396
+ domain === null ? progress : domain.bind(progress);
397
+ }
398
+ } else {
399
+ var base = index * 5 - 5;
400
+ this[base + 3] = promise;
401
+ this[base + 4] = receiver;
402
+ if (typeof fulfill === "function") {
403
+ this[base + 0] =
404
+ domain === null ? fulfill : domain.bind(fulfill);
405
+ }
406
+ if (typeof reject === "function") {
407
+ this[base + 1] =
408
+ domain === null ? reject : domain.bind(reject);
409
+ }
410
+ if (typeof progress === "function") {
411
+ this[base + 2] =
412
+ domain === null ? progress : domain.bind(progress);
413
+ }
414
+ }
415
+ this._setLength(index + 1);
416
+ return index;
417
+ };
418
+
419
+ Promise.prototype._setProxyHandlers = function (receiver, promiseSlotValue) {
420
+ var index = this._length();
421
+
422
+ if (index >= 131071 - 5) {
423
+ index = 0;
424
+ this._setLength(0);
425
+ }
426
+ if (index === 0) {
427
+ this._promise0 = promiseSlotValue;
428
+ this._receiver0 = receiver;
429
+ } else {
430
+ var base = index * 5 - 5;
431
+ this[base + 3] = promiseSlotValue;
432
+ this[base + 4] = receiver;
433
+ }
434
+ this._setLength(index + 1);
435
+ };
436
+
437
+ Promise.prototype._proxyPromiseArray = function (promiseArray, index) {
438
+ this._setProxyHandlers(promiseArray, index);
439
+ };
440
+
441
+ Promise.prototype._resolveCallback = function(value, shouldBind) {
442
+ if (this._isFollowingOrFulfilledOrRejected()) return;
443
+ if (value === this)
444
+ return this._rejectCallback(makeSelfResolutionError(), false, true);
445
+ var maybePromise = tryConvertToPromise(value, this);
446
+ if (!(maybePromise instanceof Promise)) return this._fulfill(value);
447
+
448
+ var propagationFlags = 1 | (shouldBind ? 4 : 0);
449
+ this._propagateFrom(maybePromise, propagationFlags);
450
+ var promise = maybePromise._target();
451
+ if (promise._isPending()) {
452
+ var len = this._length();
453
+ for (var i = 0; i < len; ++i) {
454
+ promise._migrateCallbacks(this, i);
455
+ }
456
+ this._setFollowing();
457
+ this._setLength(0);
458
+ this._setFollowee(promise);
459
+ } else if (promise._isFulfilled()) {
460
+ this._fulfillUnchecked(promise._value());
461
+ } else {
462
+ this._rejectUnchecked(promise._reason(),
463
+ promise._getCarriedStackTrace());
464
+ }
465
+ };
466
+
467
+ Promise.prototype._rejectCallback =
468
+ function(reason, synchronous, shouldNotMarkOriginatingFromRejection) {
469
+ if (!shouldNotMarkOriginatingFromRejection) {
470
+ util.markAsOriginatingFromRejection(reason);
471
+ }
472
+ var trace = util.ensureErrorObject(reason);
473
+ var hasStack = trace === reason;
474
+ this._attachExtraTrace(trace, synchronous ? hasStack : false);
475
+ this._reject(reason, hasStack ? undefined : trace);
476
+ };
477
+
478
+ Promise.prototype._resolveFromResolver = function (resolver) {
479
+ var promise = this;
480
+ this._captureStackTrace();
481
+ this._pushContext();
482
+ var synchronous = true;
483
+ var r = tryCatch(resolver)(function(value) {
484
+ if (promise === null) return;
485
+ promise._resolveCallback(value);
486
+ promise = null;
487
+ }, function (reason) {
488
+ if (promise === null) return;
489
+ promise._rejectCallback(reason, synchronous);
490
+ promise = null;
491
+ });
492
+ synchronous = false;
493
+ this._popContext();
494
+
495
+ if (r !== undefined && r === errorObj && promise !== null) {
496
+ promise._rejectCallback(r.e, true, true);
497
+ promise = null;
498
+ }
499
+ };
500
+
501
+ Promise.prototype._settlePromiseFromHandler = function (
502
+ handler, receiver, value, promise
503
+ ) {
504
+ if (promise._isRejected()) return;
505
+ promise._pushContext();
506
+ var x;
507
+ if (receiver === APPLY && !this._isRejected()) {
508
+ x = tryCatch(handler).apply(this._boundValue(), value);
509
+ } else {
510
+ x = tryCatch(handler).call(receiver, value);
511
+ }
512
+ promise._popContext();
513
+
514
+ if (x === errorObj || x === promise || x === NEXT_FILTER) {
515
+ var err = x === promise ? makeSelfResolutionError() : x.e;
516
+ promise._rejectCallback(err, false, true);
517
+ } else {
518
+ promise._resolveCallback(x);
519
+ }
520
+ };
521
+
522
+ Promise.prototype._target = function() {
523
+ var ret = this;
524
+ while (ret._isFollowing()) ret = ret._followee();
525
+ return ret;
526
+ };
527
+
528
+ Promise.prototype._followee = function() {
529
+ return this._rejectionHandler0;
530
+ };
531
+
532
+ Promise.prototype._setFollowee = function(promise) {
533
+ this._rejectionHandler0 = promise;
534
+ };
535
+
536
+ Promise.prototype._cleanValues = function () {
537
+ if (this._cancellable()) {
538
+ this._cancellationParent = undefined;
539
+ }
540
+ };
541
+
542
+ Promise.prototype._propagateFrom = function (parent, flags) {
543
+ if ((flags & 1) > 0 && parent._cancellable()) {
544
+ this._setCancellable();
545
+ this._cancellationParent = parent;
546
+ }
547
+ if ((flags & 4) > 0 && parent._isBound()) {
548
+ this._setBoundTo(parent._boundTo);
549
+ }
550
+ };
551
+
552
+ Promise.prototype._fulfill = function (value) {
553
+ if (this._isFollowingOrFulfilledOrRejected()) return;
554
+ this._fulfillUnchecked(value);
555
+ };
556
+
557
+ Promise.prototype._reject = function (reason, carriedStackTrace) {
558
+ if (this._isFollowingOrFulfilledOrRejected()) return;
559
+ this._rejectUnchecked(reason, carriedStackTrace);
560
+ };
561
+
562
+ Promise.prototype._settlePromiseAt = function (index) {
563
+ var promise = this._promiseAt(index);
564
+ var isPromise = promise instanceof Promise;
565
+
566
+ if (isPromise && promise._isMigrated()) {
567
+ promise._unsetIsMigrated();
568
+ return async.invoke(this._settlePromiseAt, this, index);
569
+ }
570
+ var handler = this._isFulfilled()
571
+ ? this._fulfillmentHandlerAt(index)
572
+ : this._rejectionHandlerAt(index);
573
+
574
+ var carriedStackTrace =
575
+ this._isCarryingStackTrace() ? this._getCarriedStackTrace() : undefined;
576
+ var value = this._settledValue;
577
+ var receiver = this._receiverAt(index);
578
+ this._clearCallbackDataAtIndex(index);
579
+
580
+ if (typeof handler === "function") {
581
+ if (!isPromise) {
582
+ handler.call(receiver, value, promise);
583
+ } else {
584
+ this._settlePromiseFromHandler(handler, receiver, value, promise);
585
+ }
586
+ } else if (receiver instanceof PromiseArray) {
587
+ if (!receiver._isResolved()) {
588
+ if (this._isFulfilled()) {
589
+ receiver._promiseFulfilled(value, promise);
590
+ }
591
+ else {
592
+ receiver._promiseRejected(value, promise);
593
+ }
594
+ }
595
+ } else if (isPromise) {
596
+ if (this._isFulfilled()) {
597
+ promise._fulfill(value);
598
+ } else {
599
+ promise._reject(value, carriedStackTrace);
600
+ }
601
+ }
602
+
603
+ if (index >= 4 && (index & 31) === 4)
604
+ async.invokeLater(this._setLength, this, 0);
605
+ };
606
+
607
+ Promise.prototype._clearCallbackDataAtIndex = function(index) {
608
+ if (index === 0) {
609
+ if (!this._isCarryingStackTrace()) {
610
+ this._fulfillmentHandler0 = undefined;
611
+ }
612
+ this._rejectionHandler0 =
613
+ this._progressHandler0 =
614
+ this._receiver0 =
615
+ this._promise0 = undefined;
616
+ } else {
617
+ var base = index * 5 - 5;
618
+ this[base + 3] =
619
+ this[base + 4] =
620
+ this[base + 0] =
621
+ this[base + 1] =
622
+ this[base + 2] = undefined;
623
+ }
624
+ };
625
+
626
+ Promise.prototype._isSettlePromisesQueued = function () {
627
+ return (this._bitField &
628
+ -1073741824) === -1073741824;
629
+ };
630
+
631
+ Promise.prototype._setSettlePromisesQueued = function () {
632
+ this._bitField = this._bitField | -1073741824;
633
+ };
634
+
635
+ Promise.prototype._unsetSettlePromisesQueued = function () {
636
+ this._bitField = this._bitField & (~-1073741824);
637
+ };
638
+
639
+ Promise.prototype._queueSettlePromises = function() {
640
+ async.settlePromises(this);
641
+ this._setSettlePromisesQueued();
642
+ };
643
+
644
+ Promise.prototype._fulfillUnchecked = function (value) {
645
+ if (value === this) {
646
+ var err = makeSelfResolutionError();
647
+ this._attachExtraTrace(err);
648
+ return this._rejectUnchecked(err, undefined);
649
+ }
650
+ this._setFulfilled();
651
+ this._settledValue = value;
652
+ this._cleanValues();
653
+
654
+ if (this._length() > 0) {
655
+ this._queueSettlePromises();
656
+ }
657
+ };
658
+
659
+ Promise.prototype._rejectUncheckedCheckError = function (reason) {
660
+ var trace = util.ensureErrorObject(reason);
661
+ this._rejectUnchecked(reason, trace === reason ? undefined : trace);
662
+ };
663
+
664
+ Promise.prototype._rejectUnchecked = function (reason, trace) {
665
+ if (reason === this) {
666
+ var err = makeSelfResolutionError();
667
+ this._attachExtraTrace(err);
668
+ return this._rejectUnchecked(err);
669
+ }
670
+ this._setRejected();
671
+ this._settledValue = reason;
672
+ this._cleanValues();
673
+
674
+ if (this._isFinal()) {
675
+ async.throwLater(function(e) {
676
+ if ("stack" in e) {
677
+ async.invokeFirst(
678
+ CapturedTrace.unhandledRejection, undefined, e);
679
+ }
680
+ throw e;
681
+ }, trace === undefined ? reason : trace);
682
+ return;
683
+ }
684
+
685
+ if (trace !== undefined && trace !== reason) {
686
+ this._setCarriedStackTrace(trace);
687
+ }
688
+
689
+ if (this._length() > 0) {
690
+ this._queueSettlePromises();
691
+ } else {
692
+ this._ensurePossibleRejectionHandled();
693
+ }
694
+ };
695
+
696
+ Promise.prototype._settlePromises = function () {
697
+ this._unsetSettlePromisesQueued();
698
+ var len = this._length();
699
+ for (var i = 0; i < len; i++) {
700
+ this._settlePromiseAt(i);
701
+ }
702
+ };
703
+
704
+
705
+ util.notEnumerableProp(Promise,
706
+ "_makeSelfResolutionError",
707
+ makeSelfResolutionError);
708
+
709
+ require("./progress.js")(Promise, PromiseArray);
710
+ require("./method.js")(Promise, INTERNAL, tryConvertToPromise, apiRejection);
711
+ require("./bind.js")(Promise, INTERNAL, tryConvertToPromise);
712
+ require("./finally.js")(Promise, NEXT_FILTER, tryConvertToPromise);
713
+ require("./direct_resolve.js")(Promise);
714
+ require("./synchronous_inspection.js")(Promise);
715
+ require("./join.js")(Promise, PromiseArray, tryConvertToPromise, INTERNAL);
716
+ Promise.version = "2.11.0";
717
+ Promise.Promise = Promise;
718
+ require('./map.js')(Promise, PromiseArray, apiRejection, tryConvertToPromise, INTERNAL);
719
+ require('./cancel.js')(Promise);
720
+ require('./using.js')(Promise, apiRejection, tryConvertToPromise, createContext);
721
+ require('./generators.js')(Promise, apiRejection, INTERNAL, tryConvertToPromise);
722
+ require('./nodeify.js')(Promise);
723
+ require('./call_get.js')(Promise);
724
+ require('./props.js')(Promise, PromiseArray, tryConvertToPromise, apiRejection);
725
+ require('./race.js')(Promise, INTERNAL, tryConvertToPromise, apiRejection);
726
+ require('./reduce.js')(Promise, PromiseArray, apiRejection, tryConvertToPromise, INTERNAL);
727
+ require('./settle.js')(Promise, PromiseArray);
728
+ require('./some.js')(Promise, PromiseArray, apiRejection);
729
+ require('./promisify.js')(Promise, INTERNAL);
730
+ require('./any.js')(Promise);
731
+ require('./each.js')(Promise, INTERNAL);
732
+ require('./timers.js')(Promise, INTERNAL);
733
+ require('./filter.js')(Promise, INTERNAL);
734
+
735
+ util.toFastProperties(Promise);
736
+ util.toFastProperties(Promise.prototype);
737
+ function fillTypes(value) {
738
+ var p = new Promise(INTERNAL);
739
+ p._fulfillmentHandler0 = value;
740
+ p._rejectionHandler0 = value;
741
+ p._progressHandler0 = value;
742
+ p._promise0 = value;
743
+ p._receiver0 = value;
744
+ p._settledValue = value;
745
+ }
746
+ // Complete slack tracking, opt out of field-type tracking and
747
+ // stabilize map
748
+ fillTypes({a: 1});
749
+ fillTypes({b: 2});
750
+ fillTypes({c: 3});
751
+ fillTypes(1);
752
+ fillTypes(function(){});
753
+ fillTypes(undefined);
754
+ fillTypes(false);
755
+ fillTypes(new Promise(INTERNAL));
756
+ CapturedTrace.setBounds(async.firstLineError, util.lastLineError);
757
+ return Promise;
758
+
759
+ };