browsed 0.2.9 → 0.3.5

Sign up to get free protection for your applications and to get access to all the features.
Files changed (162) hide show
  1. checksums.yaml +4 -4
  2. data/Gemfile.lock +28 -28
  3. data/browsed.gemspec +3 -4
  4. data/lib/browsed.rb +1 -1
  5. data/lib/browsed/chrome.rb +2 -2
  6. data/lib/browsed/client.rb +2 -2
  7. data/lib/browsed/firefox.rb +2 -2
  8. data/lib/browsed/version.rb +1 -1
  9. metadata +13 -166
  10. data/lib/browsed/proxies/proxy-chain-server/node_modules/.bin/portastic +0 -1
  11. data/lib/browsed/proxies/proxy-chain-server/node_modules/bluebird/LICENSE +0 -21
  12. data/lib/browsed/proxies/proxy-chain-server/node_modules/bluebird/README.md +0 -57
  13. data/lib/browsed/proxies/proxy-chain-server/node_modules/bluebird/changelog.md +0 -1
  14. data/lib/browsed/proxies/proxy-chain-server/node_modules/bluebird/js/browser/bluebird.core.js +0 -3824
  15. data/lib/browsed/proxies/proxy-chain-server/node_modules/bluebird/js/browser/bluebird.core.min.js +0 -31
  16. data/lib/browsed/proxies/proxy-chain-server/node_modules/bluebird/js/browser/bluebird.js +0 -5666
  17. data/lib/browsed/proxies/proxy-chain-server/node_modules/bluebird/js/browser/bluebird.min.js +0 -31
  18. data/lib/browsed/proxies/proxy-chain-server/node_modules/bluebird/js/release/any.js +0 -21
  19. data/lib/browsed/proxies/proxy-chain-server/node_modules/bluebird/js/release/assert.js +0 -55
  20. data/lib/browsed/proxies/proxy-chain-server/node_modules/bluebird/js/release/async.js +0 -165
  21. data/lib/browsed/proxies/proxy-chain-server/node_modules/bluebird/js/release/bind.js +0 -67
  22. data/lib/browsed/proxies/proxy-chain-server/node_modules/bluebird/js/release/bluebird.js +0 -11
  23. data/lib/browsed/proxies/proxy-chain-server/node_modules/bluebird/js/release/call_get.js +0 -123
  24. data/lib/browsed/proxies/proxy-chain-server/node_modules/bluebird/js/release/cancel.js +0 -129
  25. data/lib/browsed/proxies/proxy-chain-server/node_modules/bluebird/js/release/catch_filter.js +0 -42
  26. data/lib/browsed/proxies/proxy-chain-server/node_modules/bluebird/js/release/context.js +0 -69
  27. data/lib/browsed/proxies/proxy-chain-server/node_modules/bluebird/js/release/debuggability.js +0 -934
  28. data/lib/browsed/proxies/proxy-chain-server/node_modules/bluebird/js/release/direct_resolve.js +0 -46
  29. data/lib/browsed/proxies/proxy-chain-server/node_modules/bluebird/js/release/each.js +0 -30
  30. data/lib/browsed/proxies/proxy-chain-server/node_modules/bluebird/js/release/errors.js +0 -116
  31. data/lib/browsed/proxies/proxy-chain-server/node_modules/bluebird/js/release/es5.js +0 -80
  32. data/lib/browsed/proxies/proxy-chain-server/node_modules/bluebird/js/release/filter.js +0 -12
  33. data/lib/browsed/proxies/proxy-chain-server/node_modules/bluebird/js/release/finally.js +0 -146
  34. data/lib/browsed/proxies/proxy-chain-server/node_modules/bluebird/js/release/generators.js +0 -223
  35. data/lib/browsed/proxies/proxy-chain-server/node_modules/bluebird/js/release/join.js +0 -168
  36. data/lib/browsed/proxies/proxy-chain-server/node_modules/bluebird/js/release/map.js +0 -168
  37. data/lib/browsed/proxies/proxy-chain-server/node_modules/bluebird/js/release/method.js +0 -55
  38. data/lib/browsed/proxies/proxy-chain-server/node_modules/bluebird/js/release/nodeback.js +0 -51
  39. data/lib/browsed/proxies/proxy-chain-server/node_modules/bluebird/js/release/nodeify.js +0 -58
  40. data/lib/browsed/proxies/proxy-chain-server/node_modules/bluebird/js/release/promise.js +0 -789
  41. data/lib/browsed/proxies/proxy-chain-server/node_modules/bluebird/js/release/promise_array.js +0 -185
  42. data/lib/browsed/proxies/proxy-chain-server/node_modules/bluebird/js/release/promisify.js +0 -314
  43. data/lib/browsed/proxies/proxy-chain-server/node_modules/bluebird/js/release/props.js +0 -118
  44. data/lib/browsed/proxies/proxy-chain-server/node_modules/bluebird/js/release/queue.js +0 -73
  45. data/lib/browsed/proxies/proxy-chain-server/node_modules/bluebird/js/release/race.js +0 -49
  46. data/lib/browsed/proxies/proxy-chain-server/node_modules/bluebird/js/release/reduce.js +0 -172
  47. data/lib/browsed/proxies/proxy-chain-server/node_modules/bluebird/js/release/schedule.js +0 -62
  48. data/lib/browsed/proxies/proxy-chain-server/node_modules/bluebird/js/release/settle.js +0 -43
  49. data/lib/browsed/proxies/proxy-chain-server/node_modules/bluebird/js/release/some.js +0 -148
  50. data/lib/browsed/proxies/proxy-chain-server/node_modules/bluebird/js/release/synchronous_inspection.js +0 -103
  51. data/lib/browsed/proxies/proxy-chain-server/node_modules/bluebird/js/release/thenables.js +0 -86
  52. data/lib/browsed/proxies/proxy-chain-server/node_modules/bluebird/js/release/timers.js +0 -93
  53. data/lib/browsed/proxies/proxy-chain-server/node_modules/bluebird/js/release/using.js +0 -226
  54. data/lib/browsed/proxies/proxy-chain-server/node_modules/bluebird/js/release/util.js +0 -389
  55. data/lib/browsed/proxies/proxy-chain-server/node_modules/bluebird/package.json +0 -102
  56. data/lib/browsed/proxies/proxy-chain-server/node_modules/commander/CHANGELOG.md +0 -408
  57. data/lib/browsed/proxies/proxy-chain-server/node_modules/commander/LICENSE +0 -22
  58. data/lib/browsed/proxies/proxy-chain-server/node_modules/commander/Readme.md +0 -428
  59. data/lib/browsed/proxies/proxy-chain-server/node_modules/commander/index.js +0 -1224
  60. data/lib/browsed/proxies/proxy-chain-server/node_modules/commander/package.json +0 -70
  61. data/lib/browsed/proxies/proxy-chain-server/node_modules/commander/typings/index.d.ts +0 -310
  62. data/lib/browsed/proxies/proxy-chain-server/node_modules/debug/.coveralls.yml +0 -1
  63. data/lib/browsed/proxies/proxy-chain-server/node_modules/debug/.eslintrc +0 -11
  64. data/lib/browsed/proxies/proxy-chain-server/node_modules/debug/.npmignore +0 -9
  65. data/lib/browsed/proxies/proxy-chain-server/node_modules/debug/.travis.yml +0 -14
  66. data/lib/browsed/proxies/proxy-chain-server/node_modules/debug/CHANGELOG.md +0 -362
  67. data/lib/browsed/proxies/proxy-chain-server/node_modules/debug/LICENSE +0 -19
  68. data/lib/browsed/proxies/proxy-chain-server/node_modules/debug/Makefile +0 -50
  69. data/lib/browsed/proxies/proxy-chain-server/node_modules/debug/README.md +0 -312
  70. data/lib/browsed/proxies/proxy-chain-server/node_modules/debug/component.json +0 -19
  71. data/lib/browsed/proxies/proxy-chain-server/node_modules/debug/karma.conf.js +0 -70
  72. data/lib/browsed/proxies/proxy-chain-server/node_modules/debug/node.js +0 -1
  73. data/lib/browsed/proxies/proxy-chain-server/node_modules/debug/package.json +0 -88
  74. data/lib/browsed/proxies/proxy-chain-server/node_modules/debug/src/browser.js +0 -185
  75. data/lib/browsed/proxies/proxy-chain-server/node_modules/debug/src/debug.js +0 -202
  76. data/lib/browsed/proxies/proxy-chain-server/node_modules/debug/src/index.js +0 -10
  77. data/lib/browsed/proxies/proxy-chain-server/node_modules/debug/src/inspector-log.js +0 -15
  78. data/lib/browsed/proxies/proxy-chain-server/node_modules/debug/src/node.js +0 -248
  79. data/lib/browsed/proxies/proxy-chain-server/node_modules/ms/index.js +0 -152
  80. data/lib/browsed/proxies/proxy-chain-server/node_modules/ms/license.md +0 -21
  81. data/lib/browsed/proxies/proxy-chain-server/node_modules/ms/package.json +0 -69
  82. data/lib/browsed/proxies/proxy-chain-server/node_modules/ms/readme.md +0 -51
  83. data/lib/browsed/proxies/proxy-chain-server/node_modules/portastic/LICENSE +0 -13
  84. data/lib/browsed/proxies/proxy-chain-server/node_modules/portastic/README.md +0 -148
  85. data/lib/browsed/proxies/proxy-chain-server/node_modules/portastic/bin/portastic +0 -65
  86. data/lib/browsed/proxies/proxy-chain-server/node_modules/portastic/history.md +0 -7
  87. data/lib/browsed/proxies/proxy-chain-server/node_modules/portastic/index.js +0 -4
  88. data/lib/browsed/proxies/proxy-chain-server/node_modules/portastic/lib/monitor.js +0 -59
  89. data/lib/browsed/proxies/proxy-chain-server/node_modules/portastic/lib/portastic.js +0 -167
  90. data/lib/browsed/proxies/proxy-chain-server/node_modules/portastic/node_modules/bluebird/LICENSE +0 -21
  91. data/lib/browsed/proxies/proxy-chain-server/node_modules/portastic/node_modules/bluebird/README.md +0 -677
  92. data/lib/browsed/proxies/proxy-chain-server/node_modules/portastic/node_modules/bluebird/changelog.md +0 -1730
  93. data/lib/browsed/proxies/proxy-chain-server/node_modules/portastic/node_modules/bluebird/js/browser/bluebird.js +0 -4892
  94. data/lib/browsed/proxies/proxy-chain-server/node_modules/portastic/node_modules/bluebird/js/browser/bluebird.min.js +0 -31
  95. data/lib/browsed/proxies/proxy-chain-server/node_modules/portastic/node_modules/bluebird/js/main/any.js +0 -21
  96. data/lib/browsed/proxies/proxy-chain-server/node_modules/portastic/node_modules/bluebird/js/main/assert.js +0 -55
  97. data/lib/browsed/proxies/proxy-chain-server/node_modules/portastic/node_modules/bluebird/js/main/async.js +0 -150
  98. data/lib/browsed/proxies/proxy-chain-server/node_modules/portastic/node_modules/bluebird/js/main/bind.js +0 -72
  99. data/lib/browsed/proxies/proxy-chain-server/node_modules/portastic/node_modules/bluebird/js/main/bluebird.js +0 -11
  100. data/lib/browsed/proxies/proxy-chain-server/node_modules/portastic/node_modules/bluebird/js/main/call_get.js +0 -123
  101. data/lib/browsed/proxies/proxy-chain-server/node_modules/portastic/node_modules/bluebird/js/main/cancel.js +0 -48
  102. data/lib/browsed/proxies/proxy-chain-server/node_modules/portastic/node_modules/bluebird/js/main/captured_trace.js +0 -493
  103. data/lib/browsed/proxies/proxy-chain-server/node_modules/portastic/node_modules/bluebird/js/main/catch_filter.js +0 -66
  104. data/lib/browsed/proxies/proxy-chain-server/node_modules/portastic/node_modules/bluebird/js/main/context.js +0 -38
  105. data/lib/browsed/proxies/proxy-chain-server/node_modules/portastic/node_modules/bluebird/js/main/debuggability.js +0 -162
  106. data/lib/browsed/proxies/proxy-chain-server/node_modules/portastic/node_modules/bluebird/js/main/direct_resolve.js +0 -63
  107. data/lib/browsed/proxies/proxy-chain-server/node_modules/portastic/node_modules/bluebird/js/main/each.js +0 -12
  108. data/lib/browsed/proxies/proxy-chain-server/node_modules/portastic/node_modules/bluebird/js/main/errors.js +0 -111
  109. data/lib/browsed/proxies/proxy-chain-server/node_modules/portastic/node_modules/bluebird/js/main/es5.js +0 -80
  110. data/lib/browsed/proxies/proxy-chain-server/node_modules/portastic/node_modules/bluebird/js/main/filter.js +0 -12
  111. data/lib/browsed/proxies/proxy-chain-server/node_modules/portastic/node_modules/bluebird/js/main/finally.js +0 -98
  112. data/lib/browsed/proxies/proxy-chain-server/node_modules/portastic/node_modules/bluebird/js/main/generators.js +0 -136
  113. data/lib/browsed/proxies/proxy-chain-server/node_modules/portastic/node_modules/bluebird/js/main/join.js +0 -107
  114. data/lib/browsed/proxies/proxy-chain-server/node_modules/portastic/node_modules/bluebird/js/main/map.js +0 -133
  115. data/lib/browsed/proxies/proxy-chain-server/node_modules/portastic/node_modules/bluebird/js/main/method.js +0 -44
  116. data/lib/browsed/proxies/proxy-chain-server/node_modules/portastic/node_modules/bluebird/js/main/nodeify.js +0 -59
  117. data/lib/browsed/proxies/proxy-chain-server/node_modules/portastic/node_modules/bluebird/js/main/progress.js +0 -76
  118. data/lib/browsed/proxies/proxy-chain-server/node_modules/portastic/node_modules/bluebird/js/main/promise.js +0 -759
  119. data/lib/browsed/proxies/proxy-chain-server/node_modules/portastic/node_modules/bluebird/js/main/promise_array.js +0 -142
  120. data/lib/browsed/proxies/proxy-chain-server/node_modules/portastic/node_modules/bluebird/js/main/promise_resolver.js +0 -123
  121. data/lib/browsed/proxies/proxy-chain-server/node_modules/portastic/node_modules/bluebird/js/main/promisify.js +0 -307
  122. data/lib/browsed/proxies/proxy-chain-server/node_modules/portastic/node_modules/bluebird/js/main/props.js +0 -79
  123. data/lib/browsed/proxies/proxy-chain-server/node_modules/portastic/node_modules/bluebird/js/main/queue.js +0 -90
  124. data/lib/browsed/proxies/proxy-chain-server/node_modules/portastic/node_modules/bluebird/js/main/race.js +0 -47
  125. data/lib/browsed/proxies/proxy-chain-server/node_modules/portastic/node_modules/bluebird/js/main/reduce.js +0 -148
  126. data/lib/browsed/proxies/proxy-chain-server/node_modules/portastic/node_modules/bluebird/js/main/schedule.js +0 -35
  127. data/lib/browsed/proxies/proxy-chain-server/node_modules/portastic/node_modules/bluebird/js/main/settle.js +0 -40
  128. data/lib/browsed/proxies/proxy-chain-server/node_modules/portastic/node_modules/bluebird/js/main/some.js +0 -125
  129. data/lib/browsed/proxies/proxy-chain-server/node_modules/portastic/node_modules/bluebird/js/main/synchronous_inspection.js +0 -94
  130. data/lib/browsed/proxies/proxy-chain-server/node_modules/portastic/node_modules/bluebird/js/main/thenables.js +0 -84
  131. data/lib/browsed/proxies/proxy-chain-server/node_modules/portastic/node_modules/bluebird/js/main/timers.js +0 -64
  132. data/lib/browsed/proxies/proxy-chain-server/node_modules/portastic/node_modules/bluebird/js/main/using.js +0 -213
  133. data/lib/browsed/proxies/proxy-chain-server/node_modules/portastic/node_modules/bluebird/js/main/util.js +0 -321
  134. data/lib/browsed/proxies/proxy-chain-server/node_modules/portastic/node_modules/bluebird/package.json +0 -103
  135. data/lib/browsed/proxies/proxy-chain-server/node_modules/portastic/package.json +0 -69
  136. data/lib/browsed/proxies/proxy-chain-server/node_modules/proxy-chain/CHANGELOG.md +0 -109
  137. data/lib/browsed/proxies/proxy-chain-server/node_modules/proxy-chain/LICENSE +0 -201
  138. data/lib/browsed/proxies/proxy-chain-server/node_modules/proxy-chain/README.md +0 -278
  139. data/lib/browsed/proxies/proxy-chain-server/node_modules/proxy-chain/build/anonymize_proxy.js +0 -100
  140. data/lib/browsed/proxies/proxy-chain-server/node_modules/proxy-chain/build/handler_base.js +0 -319
  141. data/lib/browsed/proxies/proxy-chain-server/node_modules/proxy-chain/build/handler_custom_response.js +0 -96
  142. data/lib/browsed/proxies/proxy-chain-server/node_modules/proxy-chain/build/handler_forward.js +0 -173
  143. data/lib/browsed/proxies/proxy-chain-server/node_modules/proxy-chain/build/handler_tunnel_chain.js +0 -132
  144. data/lib/browsed/proxies/proxy-chain-server/node_modules/proxy-chain/build/handler_tunnel_direct.js +0 -89
  145. data/lib/browsed/proxies/proxy-chain-server/node_modules/proxy-chain/build/handler_tunnel_tcp_chain.js +0 -271
  146. data/lib/browsed/proxies/proxy-chain-server/node_modules/proxy-chain/build/index.js +0 -26
  147. data/lib/browsed/proxies/proxy-chain-server/node_modules/proxy-chain/build/run_locally.js +0 -66
  148. data/lib/browsed/proxies/proxy-chain-server/node_modules/proxy-chain/build/server.js +0 -595
  149. data/lib/browsed/proxies/proxy-chain-server/node_modules/proxy-chain/build/tcp_tunnel.js +0 -138
  150. data/lib/browsed/proxies/proxy-chain-server/node_modules/proxy-chain/build/testing_tcp_service.js +0 -37
  151. data/lib/browsed/proxies/proxy-chain-server/node_modules/proxy-chain/build/tools.js +0 -220
  152. data/lib/browsed/proxies/proxy-chain-server/node_modules/proxy-chain/package.json +0 -104
  153. data/lib/browsed/proxies/proxy-chain-server/node_modules/underscore/LICENSE +0 -23
  154. data/lib/browsed/proxies/proxy-chain-server/node_modules/underscore/README.md +0 -28
  155. data/lib/browsed/proxies/proxy-chain-server/node_modules/underscore/package.json +0 -81
  156. data/lib/browsed/proxies/proxy-chain-server/node_modules/underscore/underscore-min.js +0 -5
  157. data/lib/browsed/proxies/proxy-chain-server/node_modules/underscore/underscore-min.js.map +0 -1
  158. data/lib/browsed/proxies/proxy-chain-server/node_modules/underscore/underscore.js +0 -1692
  159. data/lib/browsed/proxies/proxy-chain-server/package-lock.json +0 -63
  160. data/lib/browsed/proxies/proxy-chain-server/package.json +0 -15
  161. data/lib/browsed/proxies/proxy-chain-server/server.js +0 -25
  162. data/lib/browsed/proxies/proxy_chain.rb +0 -39
@@ -1,4892 +0,0 @@
1
- /* @preserve
2
- * The MIT License (MIT)
3
- *
4
- * Copyright (c) 2013-2015 Petka Antonov
5
- *
6
- * Permission is hereby granted, free of charge, to any person obtaining a copy
7
- * of this software and associated documentation files (the "Software"), to deal
8
- * in the Software without restriction, including without limitation the rights
9
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10
- * copies of the Software, and to permit persons to whom the Software is
11
- * furnished to do so, subject to the following conditions:
12
- *
13
- * The above copyright notice and this permission notice shall be included in
14
- * all copies or substantial portions of the Software.
15
- *
16
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
22
- * THE SOFTWARE.
23
- *
24
- */
25
- /**
26
- * bluebird build version 2.11.0
27
- * Features enabled: core, race, call_get, generators, map, nodeify, promisify, props, reduce, settle, some, cancel, using, filter, any, each, timers
28
- */
29
- !function(e){if("object"==typeof exports&&"undefined"!=typeof module)module.exports=e();else if("function"==typeof define&&define.amd)define([],e);else{var f;"undefined"!=typeof window?f=window:"undefined"!=typeof global?f=global:"undefined"!=typeof self&&(f=self),f.Promise=e()}}(function(){var define,module,exports;return (function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof _dereq_=="function"&&_dereq_;if(!u&&a)return a(o,!0);if(i)return i(o,!0);var f=new Error("Cannot find module '"+o+"'");throw f.code="MODULE_NOT_FOUND",f}var l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var n=t[o][1][e];return s(n?n:e)},l,l.exports,e,t,n,r)}return n[o].exports}var i=typeof _dereq_=="function"&&_dereq_;for(var o=0;o<r.length;o++)s(r[o]);return s})({1:[function(_dereq_,module,exports){
30
- "use strict";
31
- module.exports = function(Promise) {
32
- var SomePromiseArray = Promise._SomePromiseArray;
33
- function any(promises) {
34
- var ret = new SomePromiseArray(promises);
35
- var promise = ret.promise();
36
- ret.setHowMany(1);
37
- ret.setUnwrap();
38
- ret.init();
39
- return promise;
40
- }
41
-
42
- Promise.any = function (promises) {
43
- return any(promises);
44
- };
45
-
46
- Promise.prototype.any = function () {
47
- return any(this);
48
- };
49
-
50
- };
51
-
52
- },{}],2:[function(_dereq_,module,exports){
53
- "use strict";
54
- var firstLineError;
55
- try {throw new Error(); } catch (e) {firstLineError = e;}
56
- var schedule = _dereq_("./schedule.js");
57
- var Queue = _dereq_("./queue.js");
58
- var util = _dereq_("./util.js");
59
-
60
- function Async() {
61
- this._isTickUsed = false;
62
- this._lateQueue = new Queue(16);
63
- this._normalQueue = new Queue(16);
64
- this._trampolineEnabled = true;
65
- var self = this;
66
- this.drainQueues = function () {
67
- self._drainQueues();
68
- };
69
- this._schedule =
70
- schedule.isStatic ? schedule(this.drainQueues) : schedule;
71
- }
72
-
73
- Async.prototype.disableTrampolineIfNecessary = function() {
74
- if (util.hasDevTools) {
75
- this._trampolineEnabled = false;
76
- }
77
- };
78
-
79
- Async.prototype.enableTrampoline = function() {
80
- if (!this._trampolineEnabled) {
81
- this._trampolineEnabled = true;
82
- this._schedule = function(fn) {
83
- setTimeout(fn, 0);
84
- };
85
- }
86
- };
87
-
88
- Async.prototype.haveItemsQueued = function () {
89
- return this._normalQueue.length() > 0;
90
- };
91
-
92
- Async.prototype.throwLater = function(fn, arg) {
93
- if (arguments.length === 1) {
94
- arg = fn;
95
- fn = function () { throw arg; };
96
- }
97
- if (typeof setTimeout !== "undefined") {
98
- setTimeout(function() {
99
- fn(arg);
100
- }, 0);
101
- } else try {
102
- this._schedule(function() {
103
- fn(arg);
104
- });
105
- } catch (e) {
106
- throw new Error("No async scheduler available\u000a\u000a See http://goo.gl/m3OTXk\u000a");
107
- }
108
- };
109
-
110
- function AsyncInvokeLater(fn, receiver, arg) {
111
- this._lateQueue.push(fn, receiver, arg);
112
- this._queueTick();
113
- }
114
-
115
- function AsyncInvoke(fn, receiver, arg) {
116
- this._normalQueue.push(fn, receiver, arg);
117
- this._queueTick();
118
- }
119
-
120
- function AsyncSettlePromises(promise) {
121
- this._normalQueue._pushOne(promise);
122
- this._queueTick();
123
- }
124
-
125
- if (!util.hasDevTools) {
126
- Async.prototype.invokeLater = AsyncInvokeLater;
127
- Async.prototype.invoke = AsyncInvoke;
128
- Async.prototype.settlePromises = AsyncSettlePromises;
129
- } else {
130
- if (schedule.isStatic) {
131
- schedule = function(fn) { setTimeout(fn, 0); };
132
- }
133
- Async.prototype.invokeLater = function (fn, receiver, arg) {
134
- if (this._trampolineEnabled) {
135
- AsyncInvokeLater.call(this, fn, receiver, arg);
136
- } else {
137
- this._schedule(function() {
138
- setTimeout(function() {
139
- fn.call(receiver, arg);
140
- }, 100);
141
- });
142
- }
143
- };
144
-
145
- Async.prototype.invoke = function (fn, receiver, arg) {
146
- if (this._trampolineEnabled) {
147
- AsyncInvoke.call(this, fn, receiver, arg);
148
- } else {
149
- this._schedule(function() {
150
- fn.call(receiver, arg);
151
- });
152
- }
153
- };
154
-
155
- Async.prototype.settlePromises = function(promise) {
156
- if (this._trampolineEnabled) {
157
- AsyncSettlePromises.call(this, promise);
158
- } else {
159
- this._schedule(function() {
160
- promise._settlePromises();
161
- });
162
- }
163
- };
164
- }
165
-
166
- Async.prototype.invokeFirst = function (fn, receiver, arg) {
167
- this._normalQueue.unshift(fn, receiver, arg);
168
- this._queueTick();
169
- };
170
-
171
- Async.prototype._drainQueue = function(queue) {
172
- while (queue.length() > 0) {
173
- var fn = queue.shift();
174
- if (typeof fn !== "function") {
175
- fn._settlePromises();
176
- continue;
177
- }
178
- var receiver = queue.shift();
179
- var arg = queue.shift();
180
- fn.call(receiver, arg);
181
- }
182
- };
183
-
184
- Async.prototype._drainQueues = function () {
185
- this._drainQueue(this._normalQueue);
186
- this._reset();
187
- this._drainQueue(this._lateQueue);
188
- };
189
-
190
- Async.prototype._queueTick = function () {
191
- if (!this._isTickUsed) {
192
- this._isTickUsed = true;
193
- this._schedule(this.drainQueues);
194
- }
195
- };
196
-
197
- Async.prototype._reset = function () {
198
- this._isTickUsed = false;
199
- };
200
-
201
- module.exports = new Async();
202
- module.exports.firstLineError = firstLineError;
203
-
204
- },{"./queue.js":28,"./schedule.js":31,"./util.js":38}],3:[function(_dereq_,module,exports){
205
- "use strict";
206
- module.exports = function(Promise, INTERNAL, tryConvertToPromise) {
207
- var rejectThis = function(_, e) {
208
- this._reject(e);
209
- };
210
-
211
- var targetRejected = function(e, context) {
212
- context.promiseRejectionQueued = true;
213
- context.bindingPromise._then(rejectThis, rejectThis, null, this, e);
214
- };
215
-
216
- var bindingResolved = function(thisArg, context) {
217
- if (this._isPending()) {
218
- this._resolveCallback(context.target);
219
- }
220
- };
221
-
222
- var bindingRejected = function(e, context) {
223
- if (!context.promiseRejectionQueued) this._reject(e);
224
- };
225
-
226
- Promise.prototype.bind = function (thisArg) {
227
- var maybePromise = tryConvertToPromise(thisArg);
228
- var ret = new Promise(INTERNAL);
229
- ret._propagateFrom(this, 1);
230
- var target = this._target();
231
-
232
- ret._setBoundTo(maybePromise);
233
- if (maybePromise instanceof Promise) {
234
- var context = {
235
- promiseRejectionQueued: false,
236
- promise: ret,
237
- target: target,
238
- bindingPromise: maybePromise
239
- };
240
- target._then(INTERNAL, targetRejected, ret._progress, ret, context);
241
- maybePromise._then(
242
- bindingResolved, bindingRejected, ret._progress, ret, context);
243
- } else {
244
- ret._resolveCallback(target);
245
- }
246
- return ret;
247
- };
248
-
249
- Promise.prototype._setBoundTo = function (obj) {
250
- if (obj !== undefined) {
251
- this._bitField = this._bitField | 131072;
252
- this._boundTo = obj;
253
- } else {
254
- this._bitField = this._bitField & (~131072);
255
- }
256
- };
257
-
258
- Promise.prototype._isBound = function () {
259
- return (this._bitField & 131072) === 131072;
260
- };
261
-
262
- Promise.bind = function (thisArg, value) {
263
- var maybePromise = tryConvertToPromise(thisArg);
264
- var ret = new Promise(INTERNAL);
265
-
266
- ret._setBoundTo(maybePromise);
267
- if (maybePromise instanceof Promise) {
268
- maybePromise._then(function() {
269
- ret._resolveCallback(value);
270
- }, ret._reject, ret._progress, ret, null);
271
- } else {
272
- ret._resolveCallback(value);
273
- }
274
- return ret;
275
- };
276
- };
277
-
278
- },{}],4:[function(_dereq_,module,exports){
279
- "use strict";
280
- var old;
281
- if (typeof Promise !== "undefined") old = Promise;
282
- function noConflict() {
283
- try { if (Promise === bluebird) Promise = old; }
284
- catch (e) {}
285
- return bluebird;
286
- }
287
- var bluebird = _dereq_("./promise.js")();
288
- bluebird.noConflict = noConflict;
289
- module.exports = bluebird;
290
-
291
- },{"./promise.js":23}],5:[function(_dereq_,module,exports){
292
- "use strict";
293
- var cr = Object.create;
294
- if (cr) {
295
- var callerCache = cr(null);
296
- var getterCache = cr(null);
297
- callerCache[" size"] = getterCache[" size"] = 0;
298
- }
299
-
300
- module.exports = function(Promise) {
301
- var util = _dereq_("./util.js");
302
- var canEvaluate = util.canEvaluate;
303
- var isIdentifier = util.isIdentifier;
304
-
305
- var getMethodCaller;
306
- var getGetter;
307
- if (!true) {
308
- var makeMethodCaller = function (methodName) {
309
- return new Function("ensureMethod", " \n\
310
- return function(obj) { \n\
311
- 'use strict' \n\
312
- var len = this.length; \n\
313
- ensureMethod(obj, 'methodName'); \n\
314
- switch(len) { \n\
315
- case 1: return obj.methodName(this[0]); \n\
316
- case 2: return obj.methodName(this[0], this[1]); \n\
317
- case 3: return obj.methodName(this[0], this[1], this[2]); \n\
318
- case 0: return obj.methodName(); \n\
319
- default: \n\
320
- return obj.methodName.apply(obj, this); \n\
321
- } \n\
322
- }; \n\
323
- ".replace(/methodName/g, methodName))(ensureMethod);
324
- };
325
-
326
- var makeGetter = function (propertyName) {
327
- return new Function("obj", " \n\
328
- 'use strict'; \n\
329
- return obj.propertyName; \n\
330
- ".replace("propertyName", propertyName));
331
- };
332
-
333
- var getCompiled = function(name, compiler, cache) {
334
- var ret = cache[name];
335
- if (typeof ret !== "function") {
336
- if (!isIdentifier(name)) {
337
- return null;
338
- }
339
- ret = compiler(name);
340
- cache[name] = ret;
341
- cache[" size"]++;
342
- if (cache[" size"] > 512) {
343
- var keys = Object.keys(cache);
344
- for (var i = 0; i < 256; ++i) delete cache[keys[i]];
345
- cache[" size"] = keys.length - 256;
346
- }
347
- }
348
- return ret;
349
- };
350
-
351
- getMethodCaller = function(name) {
352
- return getCompiled(name, makeMethodCaller, callerCache);
353
- };
354
-
355
- getGetter = function(name) {
356
- return getCompiled(name, makeGetter, getterCache);
357
- };
358
- }
359
-
360
- function ensureMethod(obj, methodName) {
361
- var fn;
362
- if (obj != null) fn = obj[methodName];
363
- if (typeof fn !== "function") {
364
- var message = "Object " + util.classString(obj) + " has no method '" +
365
- util.toString(methodName) + "'";
366
- throw new Promise.TypeError(message);
367
- }
368
- return fn;
369
- }
370
-
371
- function caller(obj) {
372
- var methodName = this.pop();
373
- var fn = ensureMethod(obj, methodName);
374
- return fn.apply(obj, this);
375
- }
376
- Promise.prototype.call = function (methodName) {
377
- var $_len = arguments.length;var args = new Array($_len - 1); for(var $_i = 1; $_i < $_len; ++$_i) {args[$_i - 1] = arguments[$_i];}
378
- if (!true) {
379
- if (canEvaluate) {
380
- var maybeCaller = getMethodCaller(methodName);
381
- if (maybeCaller !== null) {
382
- return this._then(
383
- maybeCaller, undefined, undefined, args, undefined);
384
- }
385
- }
386
- }
387
- args.push(methodName);
388
- return this._then(caller, undefined, undefined, args, undefined);
389
- };
390
-
391
- function namedGetter(obj) {
392
- return obj[this];
393
- }
394
- function indexedGetter(obj) {
395
- var index = +this;
396
- if (index < 0) index = Math.max(0, index + obj.length);
397
- return obj[index];
398
- }
399
- Promise.prototype.get = function (propertyName) {
400
- var isIndex = (typeof propertyName === "number");
401
- var getter;
402
- if (!isIndex) {
403
- if (canEvaluate) {
404
- var maybeGetter = getGetter(propertyName);
405
- getter = maybeGetter !== null ? maybeGetter : namedGetter;
406
- } else {
407
- getter = namedGetter;
408
- }
409
- } else {
410
- getter = indexedGetter;
411
- }
412
- return this._then(getter, undefined, undefined, propertyName, undefined);
413
- };
414
- };
415
-
416
- },{"./util.js":38}],6:[function(_dereq_,module,exports){
417
- "use strict";
418
- module.exports = function(Promise) {
419
- var errors = _dereq_("./errors.js");
420
- var async = _dereq_("./async.js");
421
- var CancellationError = errors.CancellationError;
422
-
423
- Promise.prototype._cancel = function (reason) {
424
- if (!this.isCancellable()) return this;
425
- var parent;
426
- var promiseToReject = this;
427
- while ((parent = promiseToReject._cancellationParent) !== undefined &&
428
- parent.isCancellable()) {
429
- promiseToReject = parent;
430
- }
431
- this._unsetCancellable();
432
- promiseToReject._target()._rejectCallback(reason, false, true);
433
- };
434
-
435
- Promise.prototype.cancel = function (reason) {
436
- if (!this.isCancellable()) return this;
437
- if (reason === undefined) reason = new CancellationError();
438
- async.invokeLater(this._cancel, this, reason);
439
- return this;
440
- };
441
-
442
- Promise.prototype.cancellable = function () {
443
- if (this._cancellable()) return this;
444
- async.enableTrampoline();
445
- this._setCancellable();
446
- this._cancellationParent = undefined;
447
- return this;
448
- };
449
-
450
- Promise.prototype.uncancellable = function () {
451
- var ret = this.then();
452
- ret._unsetCancellable();
453
- return ret;
454
- };
455
-
456
- Promise.prototype.fork = function (didFulfill, didReject, didProgress) {
457
- var ret = this._then(didFulfill, didReject, didProgress,
458
- undefined, undefined);
459
-
460
- ret._setCancellable();
461
- ret._cancellationParent = undefined;
462
- return ret;
463
- };
464
- };
465
-
466
- },{"./async.js":2,"./errors.js":13}],7:[function(_dereq_,module,exports){
467
- "use strict";
468
- module.exports = function() {
469
- var async = _dereq_("./async.js");
470
- var util = _dereq_("./util.js");
471
- var bluebirdFramePattern =
472
- /[\\\/]bluebird[\\\/]js[\\\/](main|debug|zalgo|instrumented)/;
473
- var stackFramePattern = null;
474
- var formatStack = null;
475
- var indentStackFrames = false;
476
- var warn;
477
-
478
- function CapturedTrace(parent) {
479
- this._parent = parent;
480
- var length = this._length = 1 + (parent === undefined ? 0 : parent._length);
481
- captureStackTrace(this, CapturedTrace);
482
- if (length > 32) this.uncycle();
483
- }
484
- util.inherits(CapturedTrace, Error);
485
-
486
- CapturedTrace.prototype.uncycle = function() {
487
- var length = this._length;
488
- if (length < 2) return;
489
- var nodes = [];
490
- var stackToIndex = {};
491
-
492
- for (var i = 0, node = this; node !== undefined; ++i) {
493
- nodes.push(node);
494
- node = node._parent;
495
- }
496
- length = this._length = i;
497
- for (var i = length - 1; i >= 0; --i) {
498
- var stack = nodes[i].stack;
499
- if (stackToIndex[stack] === undefined) {
500
- stackToIndex[stack] = i;
501
- }
502
- }
503
- for (var i = 0; i < length; ++i) {
504
- var currentStack = nodes[i].stack;
505
- var index = stackToIndex[currentStack];
506
- if (index !== undefined && index !== i) {
507
- if (index > 0) {
508
- nodes[index - 1]._parent = undefined;
509
- nodes[index - 1]._length = 1;
510
- }
511
- nodes[i]._parent = undefined;
512
- nodes[i]._length = 1;
513
- var cycleEdgeNode = i > 0 ? nodes[i - 1] : this;
514
-
515
- if (index < length - 1) {
516
- cycleEdgeNode._parent = nodes[index + 1];
517
- cycleEdgeNode._parent.uncycle();
518
- cycleEdgeNode._length =
519
- cycleEdgeNode._parent._length + 1;
520
- } else {
521
- cycleEdgeNode._parent = undefined;
522
- cycleEdgeNode._length = 1;
523
- }
524
- var currentChildLength = cycleEdgeNode._length + 1;
525
- for (var j = i - 2; j >= 0; --j) {
526
- nodes[j]._length = currentChildLength;
527
- currentChildLength++;
528
- }
529
- return;
530
- }
531
- }
532
- };
533
-
534
- CapturedTrace.prototype.parent = function() {
535
- return this._parent;
536
- };
537
-
538
- CapturedTrace.prototype.hasParent = function() {
539
- return this._parent !== undefined;
540
- };
541
-
542
- CapturedTrace.prototype.attachExtraTrace = function(error) {
543
- if (error.__stackCleaned__) return;
544
- this.uncycle();
545
- var parsed = CapturedTrace.parseStackAndMessage(error);
546
- var message = parsed.message;
547
- var stacks = [parsed.stack];
548
-
549
- var trace = this;
550
- while (trace !== undefined) {
551
- stacks.push(cleanStack(trace.stack.split("\n")));
552
- trace = trace._parent;
553
- }
554
- removeCommonRoots(stacks);
555
- removeDuplicateOrEmptyJumps(stacks);
556
- util.notEnumerableProp(error, "stack", reconstructStack(message, stacks));
557
- util.notEnumerableProp(error, "__stackCleaned__", true);
558
- };
559
-
560
- function reconstructStack(message, stacks) {
561
- for (var i = 0; i < stacks.length - 1; ++i) {
562
- stacks[i].push("From previous event:");
563
- stacks[i] = stacks[i].join("\n");
564
- }
565
- if (i < stacks.length) {
566
- stacks[i] = stacks[i].join("\n");
567
- }
568
- return message + "\n" + stacks.join("\n");
569
- }
570
-
571
- function removeDuplicateOrEmptyJumps(stacks) {
572
- for (var i = 0; i < stacks.length; ++i) {
573
- if (stacks[i].length === 0 ||
574
- ((i + 1 < stacks.length) && stacks[i][0] === stacks[i+1][0])) {
575
- stacks.splice(i, 1);
576
- i--;
577
- }
578
- }
579
- }
580
-
581
- function removeCommonRoots(stacks) {
582
- var current = stacks[0];
583
- for (var i = 1; i < stacks.length; ++i) {
584
- var prev = stacks[i];
585
- var currentLastIndex = current.length - 1;
586
- var currentLastLine = current[currentLastIndex];
587
- var commonRootMeetPoint = -1;
588
-
589
- for (var j = prev.length - 1; j >= 0; --j) {
590
- if (prev[j] === currentLastLine) {
591
- commonRootMeetPoint = j;
592
- break;
593
- }
594
- }
595
-
596
- for (var j = commonRootMeetPoint; j >= 0; --j) {
597
- var line = prev[j];
598
- if (current[currentLastIndex] === line) {
599
- current.pop();
600
- currentLastIndex--;
601
- } else {
602
- break;
603
- }
604
- }
605
- current = prev;
606
- }
607
- }
608
-
609
- function cleanStack(stack) {
610
- var ret = [];
611
- for (var i = 0; i < stack.length; ++i) {
612
- var line = stack[i];
613
- var isTraceLine = stackFramePattern.test(line) ||
614
- " (No stack trace)" === line;
615
- var isInternalFrame = isTraceLine && shouldIgnore(line);
616
- if (isTraceLine && !isInternalFrame) {
617
- if (indentStackFrames && line.charAt(0) !== " ") {
618
- line = " " + line;
619
- }
620
- ret.push(line);
621
- }
622
- }
623
- return ret;
624
- }
625
-
626
- function stackFramesAsArray(error) {
627
- var stack = error.stack.replace(/\s+$/g, "").split("\n");
628
- for (var i = 0; i < stack.length; ++i) {
629
- var line = stack[i];
630
- if (" (No stack trace)" === line || stackFramePattern.test(line)) {
631
- break;
632
- }
633
- }
634
- if (i > 0) {
635
- stack = stack.slice(i);
636
- }
637
- return stack;
638
- }
639
-
640
- CapturedTrace.parseStackAndMessage = function(error) {
641
- var stack = error.stack;
642
- var message = error.toString();
643
- stack = typeof stack === "string" && stack.length > 0
644
- ? stackFramesAsArray(error) : [" (No stack trace)"];
645
- return {
646
- message: message,
647
- stack: cleanStack(stack)
648
- };
649
- };
650
-
651
- CapturedTrace.formatAndLogError = function(error, title) {
652
- if (typeof console !== "undefined") {
653
- var message;
654
- if (typeof error === "object" || typeof error === "function") {
655
- var stack = error.stack;
656
- message = title + formatStack(stack, error);
657
- } else {
658
- message = title + String(error);
659
- }
660
- if (typeof warn === "function") {
661
- warn(message);
662
- } else if (typeof console.log === "function" ||
663
- typeof console.log === "object") {
664
- console.log(message);
665
- }
666
- }
667
- };
668
-
669
- CapturedTrace.unhandledRejection = function (reason) {
670
- CapturedTrace.formatAndLogError(reason, "^--- With additional stack trace: ");
671
- };
672
-
673
- CapturedTrace.isSupported = function () {
674
- return typeof captureStackTrace === "function";
675
- };
676
-
677
- CapturedTrace.fireRejectionEvent =
678
- function(name, localHandler, reason, promise) {
679
- var localEventFired = false;
680
- try {
681
- if (typeof localHandler === "function") {
682
- localEventFired = true;
683
- if (name === "rejectionHandled") {
684
- localHandler(promise);
685
- } else {
686
- localHandler(reason, promise);
687
- }
688
- }
689
- } catch (e) {
690
- async.throwLater(e);
691
- }
692
-
693
- var globalEventFired = false;
694
- try {
695
- globalEventFired = fireGlobalEvent(name, reason, promise);
696
- } catch (e) {
697
- globalEventFired = true;
698
- async.throwLater(e);
699
- }
700
-
701
- var domEventFired = false;
702
- if (fireDomEvent) {
703
- try {
704
- domEventFired = fireDomEvent(name.toLowerCase(), {
705
- reason: reason,
706
- promise: promise
707
- });
708
- } catch (e) {
709
- domEventFired = true;
710
- async.throwLater(e);
711
- }
712
- }
713
-
714
- if (!globalEventFired && !localEventFired && !domEventFired &&
715
- name === "unhandledRejection") {
716
- CapturedTrace.formatAndLogError(reason, "Unhandled rejection ");
717
- }
718
- };
719
-
720
- function formatNonError(obj) {
721
- var str;
722
- if (typeof obj === "function") {
723
- str = "[function " +
724
- (obj.name || "anonymous") +
725
- "]";
726
- } else {
727
- str = obj.toString();
728
- var ruselessToString = /\[object [a-zA-Z0-9$_]+\]/;
729
- if (ruselessToString.test(str)) {
730
- try {
731
- var newStr = JSON.stringify(obj);
732
- str = newStr;
733
- }
734
- catch(e) {
735
-
736
- }
737
- }
738
- if (str.length === 0) {
739
- str = "(empty array)";
740
- }
741
- }
742
- return ("(<" + snip(str) + ">, no stack trace)");
743
- }
744
-
745
- function snip(str) {
746
- var maxChars = 41;
747
- if (str.length < maxChars) {
748
- return str;
749
- }
750
- return str.substr(0, maxChars - 3) + "...";
751
- }
752
-
753
- var shouldIgnore = function() { return false; };
754
- var parseLineInfoRegex = /[\/<\(]([^:\/]+):(\d+):(?:\d+)\)?\s*$/;
755
- function parseLineInfo(line) {
756
- var matches = line.match(parseLineInfoRegex);
757
- if (matches) {
758
- return {
759
- fileName: matches[1],
760
- line: parseInt(matches[2], 10)
761
- };
762
- }
763
- }
764
- CapturedTrace.setBounds = function(firstLineError, lastLineError) {
765
- if (!CapturedTrace.isSupported()) return;
766
- var firstStackLines = firstLineError.stack.split("\n");
767
- var lastStackLines = lastLineError.stack.split("\n");
768
- var firstIndex = -1;
769
- var lastIndex = -1;
770
- var firstFileName;
771
- var lastFileName;
772
- for (var i = 0; i < firstStackLines.length; ++i) {
773
- var result = parseLineInfo(firstStackLines[i]);
774
- if (result) {
775
- firstFileName = result.fileName;
776
- firstIndex = result.line;
777
- break;
778
- }
779
- }
780
- for (var i = 0; i < lastStackLines.length; ++i) {
781
- var result = parseLineInfo(lastStackLines[i]);
782
- if (result) {
783
- lastFileName = result.fileName;
784
- lastIndex = result.line;
785
- break;
786
- }
787
- }
788
- if (firstIndex < 0 || lastIndex < 0 || !firstFileName || !lastFileName ||
789
- firstFileName !== lastFileName || firstIndex >= lastIndex) {
790
- return;
791
- }
792
-
793
- shouldIgnore = function(line) {
794
- if (bluebirdFramePattern.test(line)) return true;
795
- var info = parseLineInfo(line);
796
- if (info) {
797
- if (info.fileName === firstFileName &&
798
- (firstIndex <= info.line && info.line <= lastIndex)) {
799
- return true;
800
- }
801
- }
802
- return false;
803
- };
804
- };
805
-
806
- var captureStackTrace = (function stackDetection() {
807
- var v8stackFramePattern = /^\s*at\s*/;
808
- var v8stackFormatter = function(stack, error) {
809
- if (typeof stack === "string") return stack;
810
-
811
- if (error.name !== undefined &&
812
- error.message !== undefined) {
813
- return error.toString();
814
- }
815
- return formatNonError(error);
816
- };
817
-
818
- if (typeof Error.stackTraceLimit === "number" &&
819
- typeof Error.captureStackTrace === "function") {
820
- Error.stackTraceLimit = Error.stackTraceLimit + 6;
821
- stackFramePattern = v8stackFramePattern;
822
- formatStack = v8stackFormatter;
823
- var captureStackTrace = Error.captureStackTrace;
824
-
825
- shouldIgnore = function(line) {
826
- return bluebirdFramePattern.test(line);
827
- };
828
- return function(receiver, ignoreUntil) {
829
- Error.stackTraceLimit = Error.stackTraceLimit + 6;
830
- captureStackTrace(receiver, ignoreUntil);
831
- Error.stackTraceLimit = Error.stackTraceLimit - 6;
832
- };
833
- }
834
- var err = new Error();
835
-
836
- if (typeof err.stack === "string" &&
837
- err.stack.split("\n")[0].indexOf("stackDetection@") >= 0) {
838
- stackFramePattern = /@/;
839
- formatStack = v8stackFormatter;
840
- indentStackFrames = true;
841
- return function captureStackTrace(o) {
842
- o.stack = new Error().stack;
843
- };
844
- }
845
-
846
- var hasStackAfterThrow;
847
- try { throw new Error(); }
848
- catch(e) {
849
- hasStackAfterThrow = ("stack" in e);
850
- }
851
- if (!("stack" in err) && hasStackAfterThrow &&
852
- typeof Error.stackTraceLimit === "number") {
853
- stackFramePattern = v8stackFramePattern;
854
- formatStack = v8stackFormatter;
855
- return function captureStackTrace(o) {
856
- Error.stackTraceLimit = Error.stackTraceLimit + 6;
857
- try { throw new Error(); }
858
- catch(e) { o.stack = e.stack; }
859
- Error.stackTraceLimit = Error.stackTraceLimit - 6;
860
- };
861
- }
862
-
863
- formatStack = function(stack, error) {
864
- if (typeof stack === "string") return stack;
865
-
866
- if ((typeof error === "object" ||
867
- typeof error === "function") &&
868
- error.name !== undefined &&
869
- error.message !== undefined) {
870
- return error.toString();
871
- }
872
- return formatNonError(error);
873
- };
874
-
875
- return null;
876
-
877
- })([]);
878
-
879
- var fireDomEvent;
880
- var fireGlobalEvent = (function() {
881
- if (util.isNode) {
882
- return function(name, reason, promise) {
883
- if (name === "rejectionHandled") {
884
- return process.emit(name, promise);
885
- } else {
886
- return process.emit(name, reason, promise);
887
- }
888
- };
889
- } else {
890
- var customEventWorks = false;
891
- var anyEventWorks = true;
892
- try {
893
- var ev = new self.CustomEvent("test");
894
- customEventWorks = ev instanceof CustomEvent;
895
- } catch (e) {}
896
- if (!customEventWorks) {
897
- try {
898
- var event = document.createEvent("CustomEvent");
899
- event.initCustomEvent("testingtheevent", false, true, {});
900
- self.dispatchEvent(event);
901
- } catch (e) {
902
- anyEventWorks = false;
903
- }
904
- }
905
- if (anyEventWorks) {
906
- fireDomEvent = function(type, detail) {
907
- var event;
908
- if (customEventWorks) {
909
- event = new self.CustomEvent(type, {
910
- detail: detail,
911
- bubbles: false,
912
- cancelable: true
913
- });
914
- } else if (self.dispatchEvent) {
915
- event = document.createEvent("CustomEvent");
916
- event.initCustomEvent(type, false, true, detail);
917
- }
918
-
919
- return event ? !self.dispatchEvent(event) : false;
920
- };
921
- }
922
-
923
- var toWindowMethodNameMap = {};
924
- toWindowMethodNameMap["unhandledRejection"] = ("on" +
925
- "unhandledRejection").toLowerCase();
926
- toWindowMethodNameMap["rejectionHandled"] = ("on" +
927
- "rejectionHandled").toLowerCase();
928
-
929
- return function(name, reason, promise) {
930
- var methodName = toWindowMethodNameMap[name];
931
- var method = self[methodName];
932
- if (!method) return false;
933
- if (name === "rejectionHandled") {
934
- method.call(self, promise);
935
- } else {
936
- method.call(self, reason, promise);
937
- }
938
- return true;
939
- };
940
- }
941
- })();
942
-
943
- if (typeof console !== "undefined" && typeof console.warn !== "undefined") {
944
- warn = function (message) {
945
- console.warn(message);
946
- };
947
- if (util.isNode && process.stderr.isTTY) {
948
- warn = function(message) {
949
- process.stderr.write("\u001b[31m" + message + "\u001b[39m\n");
950
- };
951
- } else if (!util.isNode && typeof (new Error().stack) === "string") {
952
- warn = function(message) {
953
- console.warn("%c" + message, "color: red");
954
- };
955
- }
956
- }
957
-
958
- return CapturedTrace;
959
- };
960
-
961
- },{"./async.js":2,"./util.js":38}],8:[function(_dereq_,module,exports){
962
- "use strict";
963
- module.exports = function(NEXT_FILTER) {
964
- var util = _dereq_("./util.js");
965
- var errors = _dereq_("./errors.js");
966
- var tryCatch = util.tryCatch;
967
- var errorObj = util.errorObj;
968
- var keys = _dereq_("./es5.js").keys;
969
- var TypeError = errors.TypeError;
970
-
971
- function CatchFilter(instances, callback, promise) {
972
- this._instances = instances;
973
- this._callback = callback;
974
- this._promise = promise;
975
- }
976
-
977
- function safePredicate(predicate, e) {
978
- var safeObject = {};
979
- var retfilter = tryCatch(predicate).call(safeObject, e);
980
-
981
- if (retfilter === errorObj) return retfilter;
982
-
983
- var safeKeys = keys(safeObject);
984
- if (safeKeys.length) {
985
- errorObj.e = new TypeError("Catch filter must inherit from Error or be a simple predicate function\u000a\u000a See http://goo.gl/o84o68\u000a");
986
- return errorObj;
987
- }
988
- return retfilter;
989
- }
990
-
991
- CatchFilter.prototype.doFilter = function (e) {
992
- var cb = this._callback;
993
- var promise = this._promise;
994
- var boundTo = promise._boundValue();
995
- for (var i = 0, len = this._instances.length; i < len; ++i) {
996
- var item = this._instances[i];
997
- var itemIsErrorType = item === Error ||
998
- (item != null && item.prototype instanceof Error);
999
-
1000
- if (itemIsErrorType && e instanceof item) {
1001
- var ret = tryCatch(cb).call(boundTo, e);
1002
- if (ret === errorObj) {
1003
- NEXT_FILTER.e = ret.e;
1004
- return NEXT_FILTER;
1005
- }
1006
- return ret;
1007
- } else if (typeof item === "function" && !itemIsErrorType) {
1008
- var shouldHandle = safePredicate(item, e);
1009
- if (shouldHandle === errorObj) {
1010
- e = errorObj.e;
1011
- break;
1012
- } else if (shouldHandle) {
1013
- var ret = tryCatch(cb).call(boundTo, e);
1014
- if (ret === errorObj) {
1015
- NEXT_FILTER.e = ret.e;
1016
- return NEXT_FILTER;
1017
- }
1018
- return ret;
1019
- }
1020
- }
1021
- }
1022
- NEXT_FILTER.e = e;
1023
- return NEXT_FILTER;
1024
- };
1025
-
1026
- return CatchFilter;
1027
- };
1028
-
1029
- },{"./errors.js":13,"./es5.js":14,"./util.js":38}],9:[function(_dereq_,module,exports){
1030
- "use strict";
1031
- module.exports = function(Promise, CapturedTrace, isDebugging) {
1032
- var contextStack = [];
1033
- function Context() {
1034
- this._trace = new CapturedTrace(peekContext());
1035
- }
1036
- Context.prototype._pushContext = function () {
1037
- if (!isDebugging()) return;
1038
- if (this._trace !== undefined) {
1039
- contextStack.push(this._trace);
1040
- }
1041
- };
1042
-
1043
- Context.prototype._popContext = function () {
1044
- if (!isDebugging()) return;
1045
- if (this._trace !== undefined) {
1046
- contextStack.pop();
1047
- }
1048
- };
1049
-
1050
- function createContext() {
1051
- if (isDebugging()) return new Context();
1052
- }
1053
-
1054
- function peekContext() {
1055
- var lastIndex = contextStack.length - 1;
1056
- if (lastIndex >= 0) {
1057
- return contextStack[lastIndex];
1058
- }
1059
- return undefined;
1060
- }
1061
-
1062
- Promise.prototype._peekContext = peekContext;
1063
- Promise.prototype._pushContext = Context.prototype._pushContext;
1064
- Promise.prototype._popContext = Context.prototype._popContext;
1065
-
1066
- return createContext;
1067
- };
1068
-
1069
- },{}],10:[function(_dereq_,module,exports){
1070
- "use strict";
1071
- module.exports = function(Promise, CapturedTrace) {
1072
- var getDomain = Promise._getDomain;
1073
- var async = _dereq_("./async.js");
1074
- var Warning = _dereq_("./errors.js").Warning;
1075
- var util = _dereq_("./util.js");
1076
- var canAttachTrace = util.canAttachTrace;
1077
- var unhandledRejectionHandled;
1078
- var possiblyUnhandledRejection;
1079
- var debugging = false || (util.isNode &&
1080
- (!!process.env["BLUEBIRD_DEBUG"] ||
1081
- process.env["NODE_ENV"] === "development"));
1082
-
1083
- if (util.isNode && process.env["BLUEBIRD_DEBUG"] == 0) debugging = false;
1084
-
1085
- if (debugging) {
1086
- async.disableTrampolineIfNecessary();
1087
- }
1088
-
1089
- Promise.prototype._ignoreRejections = function() {
1090
- this._unsetRejectionIsUnhandled();
1091
- this._bitField = this._bitField | 16777216;
1092
- };
1093
-
1094
- Promise.prototype._ensurePossibleRejectionHandled = function () {
1095
- if ((this._bitField & 16777216) !== 0) return;
1096
- this._setRejectionIsUnhandled();
1097
- async.invokeLater(this._notifyUnhandledRejection, this, undefined);
1098
- };
1099
-
1100
- Promise.prototype._notifyUnhandledRejectionIsHandled = function () {
1101
- CapturedTrace.fireRejectionEvent("rejectionHandled",
1102
- unhandledRejectionHandled, undefined, this);
1103
- };
1104
-
1105
- Promise.prototype._notifyUnhandledRejection = function () {
1106
- if (this._isRejectionUnhandled()) {
1107
- var reason = this._getCarriedStackTrace() || this._settledValue;
1108
- this._setUnhandledRejectionIsNotified();
1109
- CapturedTrace.fireRejectionEvent("unhandledRejection",
1110
- possiblyUnhandledRejection, reason, this);
1111
- }
1112
- };
1113
-
1114
- Promise.prototype._setUnhandledRejectionIsNotified = function () {
1115
- this._bitField = this._bitField | 524288;
1116
- };
1117
-
1118
- Promise.prototype._unsetUnhandledRejectionIsNotified = function () {
1119
- this._bitField = this._bitField & (~524288);
1120
- };
1121
-
1122
- Promise.prototype._isUnhandledRejectionNotified = function () {
1123
- return (this._bitField & 524288) > 0;
1124
- };
1125
-
1126
- Promise.prototype._setRejectionIsUnhandled = function () {
1127
- this._bitField = this._bitField | 2097152;
1128
- };
1129
-
1130
- Promise.prototype._unsetRejectionIsUnhandled = function () {
1131
- this._bitField = this._bitField & (~2097152);
1132
- if (this._isUnhandledRejectionNotified()) {
1133
- this._unsetUnhandledRejectionIsNotified();
1134
- this._notifyUnhandledRejectionIsHandled();
1135
- }
1136
- };
1137
-
1138
- Promise.prototype._isRejectionUnhandled = function () {
1139
- return (this._bitField & 2097152) > 0;
1140
- };
1141
-
1142
- Promise.prototype._setCarriedStackTrace = function (capturedTrace) {
1143
- this._bitField = this._bitField | 1048576;
1144
- this._fulfillmentHandler0 = capturedTrace;
1145
- };
1146
-
1147
- Promise.prototype._isCarryingStackTrace = function () {
1148
- return (this._bitField & 1048576) > 0;
1149
- };
1150
-
1151
- Promise.prototype._getCarriedStackTrace = function () {
1152
- return this._isCarryingStackTrace()
1153
- ? this._fulfillmentHandler0
1154
- : undefined;
1155
- };
1156
-
1157
- Promise.prototype._captureStackTrace = function () {
1158
- if (debugging) {
1159
- this._trace = new CapturedTrace(this._peekContext());
1160
- }
1161
- return this;
1162
- };
1163
-
1164
- Promise.prototype._attachExtraTrace = function (error, ignoreSelf) {
1165
- if (debugging && canAttachTrace(error)) {
1166
- var trace = this._trace;
1167
- if (trace !== undefined) {
1168
- if (ignoreSelf) trace = trace._parent;
1169
- }
1170
- if (trace !== undefined) {
1171
- trace.attachExtraTrace(error);
1172
- } else if (!error.__stackCleaned__) {
1173
- var parsed = CapturedTrace.parseStackAndMessage(error);
1174
- util.notEnumerableProp(error, "stack",
1175
- parsed.message + "\n" + parsed.stack.join("\n"));
1176
- util.notEnumerableProp(error, "__stackCleaned__", true);
1177
- }
1178
- }
1179
- };
1180
-
1181
- Promise.prototype._warn = function(message) {
1182
- var warning = new Warning(message);
1183
- var ctx = this._peekContext();
1184
- if (ctx) {
1185
- ctx.attachExtraTrace(warning);
1186
- } else {
1187
- var parsed = CapturedTrace.parseStackAndMessage(warning);
1188
- warning.stack = parsed.message + "\n" + parsed.stack.join("\n");
1189
- }
1190
- CapturedTrace.formatAndLogError(warning, "");
1191
- };
1192
-
1193
- Promise.onPossiblyUnhandledRejection = function (fn) {
1194
- var domain = getDomain();
1195
- possiblyUnhandledRejection =
1196
- typeof fn === "function" ? (domain === null ? fn : domain.bind(fn))
1197
- : undefined;
1198
- };
1199
-
1200
- Promise.onUnhandledRejectionHandled = function (fn) {
1201
- var domain = getDomain();
1202
- unhandledRejectionHandled =
1203
- typeof fn === "function" ? (domain === null ? fn : domain.bind(fn))
1204
- : undefined;
1205
- };
1206
-
1207
- Promise.longStackTraces = function () {
1208
- if (async.haveItemsQueued() &&
1209
- debugging === false
1210
- ) {
1211
- throw new Error("cannot enable long stack traces after promises have been created\u000a\u000a See http://goo.gl/DT1qyG\u000a");
1212
- }
1213
- debugging = CapturedTrace.isSupported();
1214
- if (debugging) {
1215
- async.disableTrampolineIfNecessary();
1216
- }
1217
- };
1218
-
1219
- Promise.hasLongStackTraces = function () {
1220
- return debugging && CapturedTrace.isSupported();
1221
- };
1222
-
1223
- if (!CapturedTrace.isSupported()) {
1224
- Promise.longStackTraces = function(){};
1225
- debugging = false;
1226
- }
1227
-
1228
- return function() {
1229
- return debugging;
1230
- };
1231
- };
1232
-
1233
- },{"./async.js":2,"./errors.js":13,"./util.js":38}],11:[function(_dereq_,module,exports){
1234
- "use strict";
1235
- var util = _dereq_("./util.js");
1236
- var isPrimitive = util.isPrimitive;
1237
-
1238
- module.exports = function(Promise) {
1239
- var returner = function () {
1240
- return this;
1241
- };
1242
- var thrower = function () {
1243
- throw this;
1244
- };
1245
- var returnUndefined = function() {};
1246
- var throwUndefined = function() {
1247
- throw undefined;
1248
- };
1249
-
1250
- var wrapper = function (value, action) {
1251
- if (action === 1) {
1252
- return function () {
1253
- throw value;
1254
- };
1255
- } else if (action === 2) {
1256
- return function () {
1257
- return value;
1258
- };
1259
- }
1260
- };
1261
-
1262
-
1263
- Promise.prototype["return"] =
1264
- Promise.prototype.thenReturn = function (value) {
1265
- if (value === undefined) return this.then(returnUndefined);
1266
-
1267
- if (isPrimitive(value)) {
1268
- return this._then(
1269
- wrapper(value, 2),
1270
- undefined,
1271
- undefined,
1272
- undefined,
1273
- undefined
1274
- );
1275
- } else if (value instanceof Promise) {
1276
- value._ignoreRejections();
1277
- }
1278
- return this._then(returner, undefined, undefined, value, undefined);
1279
- };
1280
-
1281
- Promise.prototype["throw"] =
1282
- Promise.prototype.thenThrow = function (reason) {
1283
- if (reason === undefined) return this.then(throwUndefined);
1284
-
1285
- if (isPrimitive(reason)) {
1286
- return this._then(
1287
- wrapper(reason, 1),
1288
- undefined,
1289
- undefined,
1290
- undefined,
1291
- undefined
1292
- );
1293
- }
1294
- return this._then(thrower, undefined, undefined, reason, undefined);
1295
- };
1296
- };
1297
-
1298
- },{"./util.js":38}],12:[function(_dereq_,module,exports){
1299
- "use strict";
1300
- module.exports = function(Promise, INTERNAL) {
1301
- var PromiseReduce = Promise.reduce;
1302
-
1303
- Promise.prototype.each = function (fn) {
1304
- return PromiseReduce(this, fn, null, INTERNAL);
1305
- };
1306
-
1307
- Promise.each = function (promises, fn) {
1308
- return PromiseReduce(promises, fn, null, INTERNAL);
1309
- };
1310
- };
1311
-
1312
- },{}],13:[function(_dereq_,module,exports){
1313
- "use strict";
1314
- var es5 = _dereq_("./es5.js");
1315
- var Objectfreeze = es5.freeze;
1316
- var util = _dereq_("./util.js");
1317
- var inherits = util.inherits;
1318
- var notEnumerableProp = util.notEnumerableProp;
1319
-
1320
- function subError(nameProperty, defaultMessage) {
1321
- function SubError(message) {
1322
- if (!(this instanceof SubError)) return new SubError(message);
1323
- notEnumerableProp(this, "message",
1324
- typeof message === "string" ? message : defaultMessage);
1325
- notEnumerableProp(this, "name", nameProperty);
1326
- if (Error.captureStackTrace) {
1327
- Error.captureStackTrace(this, this.constructor);
1328
- } else {
1329
- Error.call(this);
1330
- }
1331
- }
1332
- inherits(SubError, Error);
1333
- return SubError;
1334
- }
1335
-
1336
- var _TypeError, _RangeError;
1337
- var Warning = subError("Warning", "warning");
1338
- var CancellationError = subError("CancellationError", "cancellation error");
1339
- var TimeoutError = subError("TimeoutError", "timeout error");
1340
- var AggregateError = subError("AggregateError", "aggregate error");
1341
- try {
1342
- _TypeError = TypeError;
1343
- _RangeError = RangeError;
1344
- } catch(e) {
1345
- _TypeError = subError("TypeError", "type error");
1346
- _RangeError = subError("RangeError", "range error");
1347
- }
1348
-
1349
- var methods = ("join pop push shift unshift slice filter forEach some " +
1350
- "every map indexOf lastIndexOf reduce reduceRight sort reverse").split(" ");
1351
-
1352
- for (var i = 0; i < methods.length; ++i) {
1353
- if (typeof Array.prototype[methods[i]] === "function") {
1354
- AggregateError.prototype[methods[i]] = Array.prototype[methods[i]];
1355
- }
1356
- }
1357
-
1358
- es5.defineProperty(AggregateError.prototype, "length", {
1359
- value: 0,
1360
- configurable: false,
1361
- writable: true,
1362
- enumerable: true
1363
- });
1364
- AggregateError.prototype["isOperational"] = true;
1365
- var level = 0;
1366
- AggregateError.prototype.toString = function() {
1367
- var indent = Array(level * 4 + 1).join(" ");
1368
- var ret = "\n" + indent + "AggregateError of:" + "\n";
1369
- level++;
1370
- indent = Array(level * 4 + 1).join(" ");
1371
- for (var i = 0; i < this.length; ++i) {
1372
- var str = this[i] === this ? "[Circular AggregateError]" : this[i] + "";
1373
- var lines = str.split("\n");
1374
- for (var j = 0; j < lines.length; ++j) {
1375
- lines[j] = indent + lines[j];
1376
- }
1377
- str = lines.join("\n");
1378
- ret += str + "\n";
1379
- }
1380
- level--;
1381
- return ret;
1382
- };
1383
-
1384
- function OperationalError(message) {
1385
- if (!(this instanceof OperationalError))
1386
- return new OperationalError(message);
1387
- notEnumerableProp(this, "name", "OperationalError");
1388
- notEnumerableProp(this, "message", message);
1389
- this.cause = message;
1390
- this["isOperational"] = true;
1391
-
1392
- if (message instanceof Error) {
1393
- notEnumerableProp(this, "message", message.message);
1394
- notEnumerableProp(this, "stack", message.stack);
1395
- } else if (Error.captureStackTrace) {
1396
- Error.captureStackTrace(this, this.constructor);
1397
- }
1398
-
1399
- }
1400
- inherits(OperationalError, Error);
1401
-
1402
- var errorTypes = Error["__BluebirdErrorTypes__"];
1403
- if (!errorTypes) {
1404
- errorTypes = Objectfreeze({
1405
- CancellationError: CancellationError,
1406
- TimeoutError: TimeoutError,
1407
- OperationalError: OperationalError,
1408
- RejectionError: OperationalError,
1409
- AggregateError: AggregateError
1410
- });
1411
- notEnumerableProp(Error, "__BluebirdErrorTypes__", errorTypes);
1412
- }
1413
-
1414
- module.exports = {
1415
- Error: Error,
1416
- TypeError: _TypeError,
1417
- RangeError: _RangeError,
1418
- CancellationError: errorTypes.CancellationError,
1419
- OperationalError: errorTypes.OperationalError,
1420
- TimeoutError: errorTypes.TimeoutError,
1421
- AggregateError: errorTypes.AggregateError,
1422
- Warning: Warning
1423
- };
1424
-
1425
- },{"./es5.js":14,"./util.js":38}],14:[function(_dereq_,module,exports){
1426
- var isES5 = (function(){
1427
- "use strict";
1428
- return this === undefined;
1429
- })();
1430
-
1431
- if (isES5) {
1432
- module.exports = {
1433
- freeze: Object.freeze,
1434
- defineProperty: Object.defineProperty,
1435
- getDescriptor: Object.getOwnPropertyDescriptor,
1436
- keys: Object.keys,
1437
- names: Object.getOwnPropertyNames,
1438
- getPrototypeOf: Object.getPrototypeOf,
1439
- isArray: Array.isArray,
1440
- isES5: isES5,
1441
- propertyIsWritable: function(obj, prop) {
1442
- var descriptor = Object.getOwnPropertyDescriptor(obj, prop);
1443
- return !!(!descriptor || descriptor.writable || descriptor.set);
1444
- }
1445
- };
1446
- } else {
1447
- var has = {}.hasOwnProperty;
1448
- var str = {}.toString;
1449
- var proto = {}.constructor.prototype;
1450
-
1451
- var ObjectKeys = function (o) {
1452
- var ret = [];
1453
- for (var key in o) {
1454
- if (has.call(o, key)) {
1455
- ret.push(key);
1456
- }
1457
- }
1458
- return ret;
1459
- };
1460
-
1461
- var ObjectGetDescriptor = function(o, key) {
1462
- return {value: o[key]};
1463
- };
1464
-
1465
- var ObjectDefineProperty = function (o, key, desc) {
1466
- o[key] = desc.value;
1467
- return o;
1468
- };
1469
-
1470
- var ObjectFreeze = function (obj) {
1471
- return obj;
1472
- };
1473
-
1474
- var ObjectGetPrototypeOf = function (obj) {
1475
- try {
1476
- return Object(obj).constructor.prototype;
1477
- }
1478
- catch (e) {
1479
- return proto;
1480
- }
1481
- };
1482
-
1483
- var ArrayIsArray = function (obj) {
1484
- try {
1485
- return str.call(obj) === "[object Array]";
1486
- }
1487
- catch(e) {
1488
- return false;
1489
- }
1490
- };
1491
-
1492
- module.exports = {
1493
- isArray: ArrayIsArray,
1494
- keys: ObjectKeys,
1495
- names: ObjectKeys,
1496
- defineProperty: ObjectDefineProperty,
1497
- getDescriptor: ObjectGetDescriptor,
1498
- freeze: ObjectFreeze,
1499
- getPrototypeOf: ObjectGetPrototypeOf,
1500
- isES5: isES5,
1501
- propertyIsWritable: function() {
1502
- return true;
1503
- }
1504
- };
1505
- }
1506
-
1507
- },{}],15:[function(_dereq_,module,exports){
1508
- "use strict";
1509
- module.exports = function(Promise, INTERNAL) {
1510
- var PromiseMap = Promise.map;
1511
-
1512
- Promise.prototype.filter = function (fn, options) {
1513
- return PromiseMap(this, fn, options, INTERNAL);
1514
- };
1515
-
1516
- Promise.filter = function (promises, fn, options) {
1517
- return PromiseMap(promises, fn, options, INTERNAL);
1518
- };
1519
- };
1520
-
1521
- },{}],16:[function(_dereq_,module,exports){
1522
- "use strict";
1523
- module.exports = function(Promise, NEXT_FILTER, tryConvertToPromise) {
1524
- var util = _dereq_("./util.js");
1525
- var isPrimitive = util.isPrimitive;
1526
- var thrower = util.thrower;
1527
-
1528
- function returnThis() {
1529
- return this;
1530
- }
1531
- function throwThis() {
1532
- throw this;
1533
- }
1534
- function return$(r) {
1535
- return function() {
1536
- return r;
1537
- };
1538
- }
1539
- function throw$(r) {
1540
- return function() {
1541
- throw r;
1542
- };
1543
- }
1544
- function promisedFinally(ret, reasonOrValue, isFulfilled) {
1545
- var then;
1546
- if (isPrimitive(reasonOrValue)) {
1547
- then = isFulfilled ? return$(reasonOrValue) : throw$(reasonOrValue);
1548
- } else {
1549
- then = isFulfilled ? returnThis : throwThis;
1550
- }
1551
- return ret._then(then, thrower, undefined, reasonOrValue, undefined);
1552
- }
1553
-
1554
- function finallyHandler(reasonOrValue) {
1555
- var promise = this.promise;
1556
- var handler = this.handler;
1557
-
1558
- var ret = promise._isBound()
1559
- ? handler.call(promise._boundValue())
1560
- : handler();
1561
-
1562
- if (ret !== undefined) {
1563
- var maybePromise = tryConvertToPromise(ret, promise);
1564
- if (maybePromise instanceof Promise) {
1565
- maybePromise = maybePromise._target();
1566
- return promisedFinally(maybePromise, reasonOrValue,
1567
- promise.isFulfilled());
1568
- }
1569
- }
1570
-
1571
- if (promise.isRejected()) {
1572
- NEXT_FILTER.e = reasonOrValue;
1573
- return NEXT_FILTER;
1574
- } else {
1575
- return reasonOrValue;
1576
- }
1577
- }
1578
-
1579
- function tapHandler(value) {
1580
- var promise = this.promise;
1581
- var handler = this.handler;
1582
-
1583
- var ret = promise._isBound()
1584
- ? handler.call(promise._boundValue(), value)
1585
- : handler(value);
1586
-
1587
- if (ret !== undefined) {
1588
- var maybePromise = tryConvertToPromise(ret, promise);
1589
- if (maybePromise instanceof Promise) {
1590
- maybePromise = maybePromise._target();
1591
- return promisedFinally(maybePromise, value, true);
1592
- }
1593
- }
1594
- return value;
1595
- }
1596
-
1597
- Promise.prototype._passThroughHandler = function (handler, isFinally) {
1598
- if (typeof handler !== "function") return this.then();
1599
-
1600
- var promiseAndHandler = {
1601
- promise: this,
1602
- handler: handler
1603
- };
1604
-
1605
- return this._then(
1606
- isFinally ? finallyHandler : tapHandler,
1607
- isFinally ? finallyHandler : undefined, undefined,
1608
- promiseAndHandler, undefined);
1609
- };
1610
-
1611
- Promise.prototype.lastly =
1612
- Promise.prototype["finally"] = function (handler) {
1613
- return this._passThroughHandler(handler, true);
1614
- };
1615
-
1616
- Promise.prototype.tap = function (handler) {
1617
- return this._passThroughHandler(handler, false);
1618
- };
1619
- };
1620
-
1621
- },{"./util.js":38}],17:[function(_dereq_,module,exports){
1622
- "use strict";
1623
- module.exports = function(Promise,
1624
- apiRejection,
1625
- INTERNAL,
1626
- tryConvertToPromise) {
1627
- var errors = _dereq_("./errors.js");
1628
- var TypeError = errors.TypeError;
1629
- var util = _dereq_("./util.js");
1630
- var errorObj = util.errorObj;
1631
- var tryCatch = util.tryCatch;
1632
- var yieldHandlers = [];
1633
-
1634
- function promiseFromYieldHandler(value, yieldHandlers, traceParent) {
1635
- for (var i = 0; i < yieldHandlers.length; ++i) {
1636
- traceParent._pushContext();
1637
- var result = tryCatch(yieldHandlers[i])(value);
1638
- traceParent._popContext();
1639
- if (result === errorObj) {
1640
- traceParent._pushContext();
1641
- var ret = Promise.reject(errorObj.e);
1642
- traceParent._popContext();
1643
- return ret;
1644
- }
1645
- var maybePromise = tryConvertToPromise(result, traceParent);
1646
- if (maybePromise instanceof Promise) return maybePromise;
1647
- }
1648
- return null;
1649
- }
1650
-
1651
- function PromiseSpawn(generatorFunction, receiver, yieldHandler, stack) {
1652
- var promise = this._promise = new Promise(INTERNAL);
1653
- promise._captureStackTrace();
1654
- this._stack = stack;
1655
- this._generatorFunction = generatorFunction;
1656
- this._receiver = receiver;
1657
- this._generator = undefined;
1658
- this._yieldHandlers = typeof yieldHandler === "function"
1659
- ? [yieldHandler].concat(yieldHandlers)
1660
- : yieldHandlers;
1661
- }
1662
-
1663
- PromiseSpawn.prototype.promise = function () {
1664
- return this._promise;
1665
- };
1666
-
1667
- PromiseSpawn.prototype._run = function () {
1668
- this._generator = this._generatorFunction.call(this._receiver);
1669
- this._receiver =
1670
- this._generatorFunction = undefined;
1671
- this._next(undefined);
1672
- };
1673
-
1674
- PromiseSpawn.prototype._continue = function (result) {
1675
- if (result === errorObj) {
1676
- return this._promise._rejectCallback(result.e, false, true);
1677
- }
1678
-
1679
- var value = result.value;
1680
- if (result.done === true) {
1681
- this._promise._resolveCallback(value);
1682
- } else {
1683
- var maybePromise = tryConvertToPromise(value, this._promise);
1684
- if (!(maybePromise instanceof Promise)) {
1685
- maybePromise =
1686
- promiseFromYieldHandler(maybePromise,
1687
- this._yieldHandlers,
1688
- this._promise);
1689
- if (maybePromise === null) {
1690
- this._throw(
1691
- new TypeError(
1692
- "A value %s was yielded that could not be treated as a promise\u000a\u000a See http://goo.gl/4Y4pDk\u000a\u000a".replace("%s", value) +
1693
- "From coroutine:\u000a" +
1694
- this._stack.split("\n").slice(1, -7).join("\n")
1695
- )
1696
- );
1697
- return;
1698
- }
1699
- }
1700
- maybePromise._then(
1701
- this._next,
1702
- this._throw,
1703
- undefined,
1704
- this,
1705
- null
1706
- );
1707
- }
1708
- };
1709
-
1710
- PromiseSpawn.prototype._throw = function (reason) {
1711
- this._promise._attachExtraTrace(reason);
1712
- this._promise._pushContext();
1713
- var result = tryCatch(this._generator["throw"])
1714
- .call(this._generator, reason);
1715
- this._promise._popContext();
1716
- this._continue(result);
1717
- };
1718
-
1719
- PromiseSpawn.prototype._next = function (value) {
1720
- this._promise._pushContext();
1721
- var result = tryCatch(this._generator.next).call(this._generator, value);
1722
- this._promise._popContext();
1723
- this._continue(result);
1724
- };
1725
-
1726
- Promise.coroutine = function (generatorFunction, options) {
1727
- if (typeof generatorFunction !== "function") {
1728
- throw new TypeError("generatorFunction must be a function\u000a\u000a See http://goo.gl/6Vqhm0\u000a");
1729
- }
1730
- var yieldHandler = Object(options).yieldHandler;
1731
- var PromiseSpawn$ = PromiseSpawn;
1732
- var stack = new Error().stack;
1733
- return function () {
1734
- var generator = generatorFunction.apply(this, arguments);
1735
- var spawn = new PromiseSpawn$(undefined, undefined, yieldHandler,
1736
- stack);
1737
- spawn._generator = generator;
1738
- spawn._next(undefined);
1739
- return spawn.promise();
1740
- };
1741
- };
1742
-
1743
- Promise.coroutine.addYieldHandler = function(fn) {
1744
- if (typeof fn !== "function") throw new TypeError("fn must be a function\u000a\u000a See http://goo.gl/916lJJ\u000a");
1745
- yieldHandlers.push(fn);
1746
- };
1747
-
1748
- Promise.spawn = function (generatorFunction) {
1749
- if (typeof generatorFunction !== "function") {
1750
- return apiRejection("generatorFunction must be a function\u000a\u000a See http://goo.gl/6Vqhm0\u000a");
1751
- }
1752
- var spawn = new PromiseSpawn(generatorFunction, this);
1753
- var ret = spawn.promise();
1754
- spawn._run(Promise.spawn);
1755
- return ret;
1756
- };
1757
- };
1758
-
1759
- },{"./errors.js":13,"./util.js":38}],18:[function(_dereq_,module,exports){
1760
- "use strict";
1761
- module.exports =
1762
- function(Promise, PromiseArray, tryConvertToPromise, INTERNAL) {
1763
- var util = _dereq_("./util.js");
1764
- var canEvaluate = util.canEvaluate;
1765
- var tryCatch = util.tryCatch;
1766
- var errorObj = util.errorObj;
1767
- var reject;
1768
-
1769
- if (!true) {
1770
- if (canEvaluate) {
1771
- var thenCallback = function(i) {
1772
- return new Function("value", "holder", " \n\
1773
- 'use strict'; \n\
1774
- holder.pIndex = value; \n\
1775
- holder.checkFulfillment(this); \n\
1776
- ".replace(/Index/g, i));
1777
- };
1778
-
1779
- var caller = function(count) {
1780
- var values = [];
1781
- for (var i = 1; i <= count; ++i) values.push("holder.p" + i);
1782
- return new Function("holder", " \n\
1783
- 'use strict'; \n\
1784
- var callback = holder.fn; \n\
1785
- return callback(values); \n\
1786
- ".replace(/values/g, values.join(", ")));
1787
- };
1788
- var thenCallbacks = [];
1789
- var callers = [undefined];
1790
- for (var i = 1; i <= 5; ++i) {
1791
- thenCallbacks.push(thenCallback(i));
1792
- callers.push(caller(i));
1793
- }
1794
-
1795
- var Holder = function(total, fn) {
1796
- this.p1 = this.p2 = this.p3 = this.p4 = this.p5 = null;
1797
- this.fn = fn;
1798
- this.total = total;
1799
- this.now = 0;
1800
- };
1801
-
1802
- Holder.prototype.callers = callers;
1803
- Holder.prototype.checkFulfillment = function(promise) {
1804
- var now = this.now;
1805
- now++;
1806
- var total = this.total;
1807
- if (now >= total) {
1808
- var handler = this.callers[total];
1809
- promise._pushContext();
1810
- var ret = tryCatch(handler)(this);
1811
- promise._popContext();
1812
- if (ret === errorObj) {
1813
- promise._rejectCallback(ret.e, false, true);
1814
- } else {
1815
- promise._resolveCallback(ret);
1816
- }
1817
- } else {
1818
- this.now = now;
1819
- }
1820
- };
1821
-
1822
- var reject = function (reason) {
1823
- this._reject(reason);
1824
- };
1825
- }
1826
- }
1827
-
1828
- Promise.join = function () {
1829
- var last = arguments.length - 1;
1830
- var fn;
1831
- if (last > 0 && typeof arguments[last] === "function") {
1832
- fn = arguments[last];
1833
- if (!true) {
1834
- if (last < 6 && canEvaluate) {
1835
- var ret = new Promise(INTERNAL);
1836
- ret._captureStackTrace();
1837
- var holder = new Holder(last, fn);
1838
- var callbacks = thenCallbacks;
1839
- for (var i = 0; i < last; ++i) {
1840
- var maybePromise = tryConvertToPromise(arguments[i], ret);
1841
- if (maybePromise instanceof Promise) {
1842
- maybePromise = maybePromise._target();
1843
- if (maybePromise._isPending()) {
1844
- maybePromise._then(callbacks[i], reject,
1845
- undefined, ret, holder);
1846
- } else if (maybePromise._isFulfilled()) {
1847
- callbacks[i].call(ret,
1848
- maybePromise._value(), holder);
1849
- } else {
1850
- ret._reject(maybePromise._reason());
1851
- }
1852
- } else {
1853
- callbacks[i].call(ret, maybePromise, holder);
1854
- }
1855
- }
1856
- return ret;
1857
- }
1858
- }
1859
- }
1860
- var $_len = arguments.length;var args = new Array($_len); for(var $_i = 0; $_i < $_len; ++$_i) {args[$_i] = arguments[$_i];}
1861
- if (fn) args.pop();
1862
- var ret = new PromiseArray(args).promise();
1863
- return fn !== undefined ? ret.spread(fn) : ret;
1864
- };
1865
-
1866
- };
1867
-
1868
- },{"./util.js":38}],19:[function(_dereq_,module,exports){
1869
- "use strict";
1870
- module.exports = function(Promise,
1871
- PromiseArray,
1872
- apiRejection,
1873
- tryConvertToPromise,
1874
- INTERNAL) {
1875
- var getDomain = Promise._getDomain;
1876
- var async = _dereq_("./async.js");
1877
- var util = _dereq_("./util.js");
1878
- var tryCatch = util.tryCatch;
1879
- var errorObj = util.errorObj;
1880
- var PENDING = {};
1881
- var EMPTY_ARRAY = [];
1882
-
1883
- function MappingPromiseArray(promises, fn, limit, _filter) {
1884
- this.constructor$(promises);
1885
- this._promise._captureStackTrace();
1886
- var domain = getDomain();
1887
- this._callback = domain === null ? fn : domain.bind(fn);
1888
- this._preservedValues = _filter === INTERNAL
1889
- ? new Array(this.length())
1890
- : null;
1891
- this._limit = limit;
1892
- this._inFlight = 0;
1893
- this._queue = limit >= 1 ? [] : EMPTY_ARRAY;
1894
- async.invoke(init, this, undefined);
1895
- }
1896
- util.inherits(MappingPromiseArray, PromiseArray);
1897
- function init() {this._init$(undefined, -2);}
1898
-
1899
- MappingPromiseArray.prototype._init = function () {};
1900
-
1901
- MappingPromiseArray.prototype._promiseFulfilled = function (value, index) {
1902
- var values = this._values;
1903
- var length = this.length();
1904
- var preservedValues = this._preservedValues;
1905
- var limit = this._limit;
1906
- if (values[index] === PENDING) {
1907
- values[index] = value;
1908
- if (limit >= 1) {
1909
- this._inFlight--;
1910
- this._drainQueue();
1911
- if (this._isResolved()) return;
1912
- }
1913
- } else {
1914
- if (limit >= 1 && this._inFlight >= limit) {
1915
- values[index] = value;
1916
- this._queue.push(index);
1917
- return;
1918
- }
1919
- if (preservedValues !== null) preservedValues[index] = value;
1920
-
1921
- var callback = this._callback;
1922
- var receiver = this._promise._boundValue();
1923
- this._promise._pushContext();
1924
- var ret = tryCatch(callback).call(receiver, value, index, length);
1925
- this._promise._popContext();
1926
- if (ret === errorObj) return this._reject(ret.e);
1927
-
1928
- var maybePromise = tryConvertToPromise(ret, this._promise);
1929
- if (maybePromise instanceof Promise) {
1930
- maybePromise = maybePromise._target();
1931
- if (maybePromise._isPending()) {
1932
- if (limit >= 1) this._inFlight++;
1933
- values[index] = PENDING;
1934
- return maybePromise._proxyPromiseArray(this, index);
1935
- } else if (maybePromise._isFulfilled()) {
1936
- ret = maybePromise._value();
1937
- } else {
1938
- return this._reject(maybePromise._reason());
1939
- }
1940
- }
1941
- values[index] = ret;
1942
- }
1943
- var totalResolved = ++this._totalResolved;
1944
- if (totalResolved >= length) {
1945
- if (preservedValues !== null) {
1946
- this._filter(values, preservedValues);
1947
- } else {
1948
- this._resolve(values);
1949
- }
1950
-
1951
- }
1952
- };
1953
-
1954
- MappingPromiseArray.prototype._drainQueue = function () {
1955
- var queue = this._queue;
1956
- var limit = this._limit;
1957
- var values = this._values;
1958
- while (queue.length > 0 && this._inFlight < limit) {
1959
- if (this._isResolved()) return;
1960
- var index = queue.pop();
1961
- this._promiseFulfilled(values[index], index);
1962
- }
1963
- };
1964
-
1965
- MappingPromiseArray.prototype._filter = function (booleans, values) {
1966
- var len = values.length;
1967
- var ret = new Array(len);
1968
- var j = 0;
1969
- for (var i = 0; i < len; ++i) {
1970
- if (booleans[i]) ret[j++] = values[i];
1971
- }
1972
- ret.length = j;
1973
- this._resolve(ret);
1974
- };
1975
-
1976
- MappingPromiseArray.prototype.preservedValues = function () {
1977
- return this._preservedValues;
1978
- };
1979
-
1980
- function map(promises, fn, options, _filter) {
1981
- var limit = typeof options === "object" && options !== null
1982
- ? options.concurrency
1983
- : 0;
1984
- limit = typeof limit === "number" &&
1985
- isFinite(limit) && limit >= 1 ? limit : 0;
1986
- return new MappingPromiseArray(promises, fn, limit, _filter);
1987
- }
1988
-
1989
- Promise.prototype.map = function (fn, options) {
1990
- if (typeof fn !== "function") return apiRejection("fn must be a function\u000a\u000a See http://goo.gl/916lJJ\u000a");
1991
-
1992
- return map(this, fn, options, null).promise();
1993
- };
1994
-
1995
- Promise.map = function (promises, fn, options, _filter) {
1996
- if (typeof fn !== "function") return apiRejection("fn must be a function\u000a\u000a See http://goo.gl/916lJJ\u000a");
1997
- return map(promises, fn, options, _filter).promise();
1998
- };
1999
-
2000
-
2001
- };
2002
-
2003
- },{"./async.js":2,"./util.js":38}],20:[function(_dereq_,module,exports){
2004
- "use strict";
2005
- module.exports =
2006
- function(Promise, INTERNAL, tryConvertToPromise, apiRejection) {
2007
- var util = _dereq_("./util.js");
2008
- var tryCatch = util.tryCatch;
2009
-
2010
- Promise.method = function (fn) {
2011
- if (typeof fn !== "function") {
2012
- throw new Promise.TypeError("fn must be a function\u000a\u000a See http://goo.gl/916lJJ\u000a");
2013
- }
2014
- return function () {
2015
- var ret = new Promise(INTERNAL);
2016
- ret._captureStackTrace();
2017
- ret._pushContext();
2018
- var value = tryCatch(fn).apply(this, arguments);
2019
- ret._popContext();
2020
- ret._resolveFromSyncValue(value);
2021
- return ret;
2022
- };
2023
- };
2024
-
2025
- Promise.attempt = Promise["try"] = function (fn, args, ctx) {
2026
- if (typeof fn !== "function") {
2027
- return apiRejection("fn must be a function\u000a\u000a See http://goo.gl/916lJJ\u000a");
2028
- }
2029
- var ret = new Promise(INTERNAL);
2030
- ret._captureStackTrace();
2031
- ret._pushContext();
2032
- var value = util.isArray(args)
2033
- ? tryCatch(fn).apply(ctx, args)
2034
- : tryCatch(fn).call(ctx, args);
2035
- ret._popContext();
2036
- ret._resolveFromSyncValue(value);
2037
- return ret;
2038
- };
2039
-
2040
- Promise.prototype._resolveFromSyncValue = function (value) {
2041
- if (value === util.errorObj) {
2042
- this._rejectCallback(value.e, false, true);
2043
- } else {
2044
- this._resolveCallback(value, true);
2045
- }
2046
- };
2047
- };
2048
-
2049
- },{"./util.js":38}],21:[function(_dereq_,module,exports){
2050
- "use strict";
2051
- module.exports = function(Promise) {
2052
- var util = _dereq_("./util.js");
2053
- var async = _dereq_("./async.js");
2054
- var tryCatch = util.tryCatch;
2055
- var errorObj = util.errorObj;
2056
-
2057
- function spreadAdapter(val, nodeback) {
2058
- var promise = this;
2059
- if (!util.isArray(val)) return successAdapter.call(promise, val, nodeback);
2060
- var ret =
2061
- tryCatch(nodeback).apply(promise._boundValue(), [null].concat(val));
2062
- if (ret === errorObj) {
2063
- async.throwLater(ret.e);
2064
- }
2065
- }
2066
-
2067
- function successAdapter(val, nodeback) {
2068
- var promise = this;
2069
- var receiver = promise._boundValue();
2070
- var ret = val === undefined
2071
- ? tryCatch(nodeback).call(receiver, null)
2072
- : tryCatch(nodeback).call(receiver, null, val);
2073
- if (ret === errorObj) {
2074
- async.throwLater(ret.e);
2075
- }
2076
- }
2077
- function errorAdapter(reason, nodeback) {
2078
- var promise = this;
2079
- if (!reason) {
2080
- var target = promise._target();
2081
- var newReason = target._getCarriedStackTrace();
2082
- newReason.cause = reason;
2083
- reason = newReason;
2084
- }
2085
- var ret = tryCatch(nodeback).call(promise._boundValue(), reason);
2086
- if (ret === errorObj) {
2087
- async.throwLater(ret.e);
2088
- }
2089
- }
2090
-
2091
- Promise.prototype.asCallback =
2092
- Promise.prototype.nodeify = function (nodeback, options) {
2093
- if (typeof nodeback == "function") {
2094
- var adapter = successAdapter;
2095
- if (options !== undefined && Object(options).spread) {
2096
- adapter = spreadAdapter;
2097
- }
2098
- this._then(
2099
- adapter,
2100
- errorAdapter,
2101
- undefined,
2102
- this,
2103
- nodeback
2104
- );
2105
- }
2106
- return this;
2107
- };
2108
- };
2109
-
2110
- },{"./async.js":2,"./util.js":38}],22:[function(_dereq_,module,exports){
2111
- "use strict";
2112
- module.exports = function(Promise, PromiseArray) {
2113
- var util = _dereq_("./util.js");
2114
- var async = _dereq_("./async.js");
2115
- var tryCatch = util.tryCatch;
2116
- var errorObj = util.errorObj;
2117
-
2118
- Promise.prototype.progressed = function (handler) {
2119
- return this._then(undefined, undefined, handler, undefined, undefined);
2120
- };
2121
-
2122
- Promise.prototype._progress = function (progressValue) {
2123
- if (this._isFollowingOrFulfilledOrRejected()) return;
2124
- this._target()._progressUnchecked(progressValue);
2125
-
2126
- };
2127
-
2128
- Promise.prototype._progressHandlerAt = function (index) {
2129
- return index === 0
2130
- ? this._progressHandler0
2131
- : this[(index << 2) + index - 5 + 2];
2132
- };
2133
-
2134
- Promise.prototype._doProgressWith = function (progression) {
2135
- var progressValue = progression.value;
2136
- var handler = progression.handler;
2137
- var promise = progression.promise;
2138
- var receiver = progression.receiver;
2139
-
2140
- var ret = tryCatch(handler).call(receiver, progressValue);
2141
- if (ret === errorObj) {
2142
- if (ret.e != null &&
2143
- ret.e.name !== "StopProgressPropagation") {
2144
- var trace = util.canAttachTrace(ret.e)
2145
- ? ret.e : new Error(util.toString(ret.e));
2146
- promise._attachExtraTrace(trace);
2147
- promise._progress(ret.e);
2148
- }
2149
- } else if (ret instanceof Promise) {
2150
- ret._then(promise._progress, null, null, promise, undefined);
2151
- } else {
2152
- promise._progress(ret);
2153
- }
2154
- };
2155
-
2156
-
2157
- Promise.prototype._progressUnchecked = function (progressValue) {
2158
- var len = this._length();
2159
- var progress = this._progress;
2160
- for (var i = 0; i < len; i++) {
2161
- var handler = this._progressHandlerAt(i);
2162
- var promise = this._promiseAt(i);
2163
- if (!(promise instanceof Promise)) {
2164
- var receiver = this._receiverAt(i);
2165
- if (typeof handler === "function") {
2166
- handler.call(receiver, progressValue, promise);
2167
- } else if (receiver instanceof PromiseArray &&
2168
- !receiver._isResolved()) {
2169
- receiver._promiseProgressed(progressValue, promise);
2170
- }
2171
- continue;
2172
- }
2173
-
2174
- if (typeof handler === "function") {
2175
- async.invoke(this._doProgressWith, this, {
2176
- handler: handler,
2177
- promise: promise,
2178
- receiver: this._receiverAt(i),
2179
- value: progressValue
2180
- });
2181
- } else {
2182
- async.invoke(progress, promise, progressValue);
2183
- }
2184
- }
2185
- };
2186
- };
2187
-
2188
- },{"./async.js":2,"./util.js":38}],23:[function(_dereq_,module,exports){
2189
- "use strict";
2190
- module.exports = function() {
2191
- var makeSelfResolutionError = function () {
2192
- return new TypeError("circular promise resolution chain\u000a\u000a See http://goo.gl/LhFpo0\u000a");
2193
- };
2194
- var reflect = function() {
2195
- return new Promise.PromiseInspection(this._target());
2196
- };
2197
- var apiRejection = function(msg) {
2198
- return Promise.reject(new TypeError(msg));
2199
- };
2200
-
2201
- var util = _dereq_("./util.js");
2202
-
2203
- var getDomain;
2204
- if (util.isNode) {
2205
- getDomain = function() {
2206
- var ret = process.domain;
2207
- if (ret === undefined) ret = null;
2208
- return ret;
2209
- };
2210
- } else {
2211
- getDomain = function() {
2212
- return null;
2213
- };
2214
- }
2215
- util.notEnumerableProp(Promise, "_getDomain", getDomain);
2216
-
2217
- var UNDEFINED_BINDING = {};
2218
- var async = _dereq_("./async.js");
2219
- var errors = _dereq_("./errors.js");
2220
- var TypeError = Promise.TypeError = errors.TypeError;
2221
- Promise.RangeError = errors.RangeError;
2222
- Promise.CancellationError = errors.CancellationError;
2223
- Promise.TimeoutError = errors.TimeoutError;
2224
- Promise.OperationalError = errors.OperationalError;
2225
- Promise.RejectionError = errors.OperationalError;
2226
- Promise.AggregateError = errors.AggregateError;
2227
- var INTERNAL = function(){};
2228
- var APPLY = {};
2229
- var NEXT_FILTER = {e: null};
2230
- var tryConvertToPromise = _dereq_("./thenables.js")(Promise, INTERNAL);
2231
- var PromiseArray =
2232
- _dereq_("./promise_array.js")(Promise, INTERNAL,
2233
- tryConvertToPromise, apiRejection);
2234
- var CapturedTrace = _dereq_("./captured_trace.js")();
2235
- var isDebugging = _dereq_("./debuggability.js")(Promise, CapturedTrace);
2236
- /*jshint unused:false*/
2237
- var createContext =
2238
- _dereq_("./context.js")(Promise, CapturedTrace, isDebugging);
2239
- var CatchFilter = _dereq_("./catch_filter.js")(NEXT_FILTER);
2240
- var PromiseResolver = _dereq_("./promise_resolver.js");
2241
- var nodebackForPromise = PromiseResolver._nodebackForPromise;
2242
- var errorObj = util.errorObj;
2243
- var tryCatch = util.tryCatch;
2244
-
2245
- function Promise(resolver) {
2246
- if (typeof resolver !== "function") {
2247
- throw new TypeError("the promise constructor requires a resolver function\u000a\u000a See http://goo.gl/EC22Yn\u000a");
2248
- }
2249
- if (this.constructor !== Promise) {
2250
- throw new TypeError("the promise constructor cannot be invoked directly\u000a\u000a See http://goo.gl/KsIlge\u000a");
2251
- }
2252
- this._bitField = 0;
2253
- this._fulfillmentHandler0 = undefined;
2254
- this._rejectionHandler0 = undefined;
2255
- this._progressHandler0 = undefined;
2256
- this._promise0 = undefined;
2257
- this._receiver0 = undefined;
2258
- this._settledValue = undefined;
2259
- if (resolver !== INTERNAL) this._resolveFromResolver(resolver);
2260
- }
2261
-
2262
- Promise.prototype.toString = function () {
2263
- return "[object Promise]";
2264
- };
2265
-
2266
- Promise.prototype.caught = Promise.prototype["catch"] = function (fn) {
2267
- var len = arguments.length;
2268
- if (len > 1) {
2269
- var catchInstances = new Array(len - 1),
2270
- j = 0, i;
2271
- for (i = 0; i < len - 1; ++i) {
2272
- var item = arguments[i];
2273
- if (typeof item === "function") {
2274
- catchInstances[j++] = item;
2275
- } else {
2276
- return Promise.reject(
2277
- new TypeError("Catch filter must inherit from Error or be a simple predicate function\u000a\u000a See http://goo.gl/o84o68\u000a"));
2278
- }
2279
- }
2280
- catchInstances.length = j;
2281
- fn = arguments[i];
2282
- var catchFilter = new CatchFilter(catchInstances, fn, this);
2283
- return this._then(undefined, catchFilter.doFilter, undefined,
2284
- catchFilter, undefined);
2285
- }
2286
- return this._then(undefined, fn, undefined, undefined, undefined);
2287
- };
2288
-
2289
- Promise.prototype.reflect = function () {
2290
- return this._then(reflect, reflect, undefined, this, undefined);
2291
- };
2292
-
2293
- Promise.prototype.then = function (didFulfill, didReject, didProgress) {
2294
- if (isDebugging() && arguments.length > 0 &&
2295
- typeof didFulfill !== "function" &&
2296
- typeof didReject !== "function") {
2297
- var msg = ".then() only accepts functions but was passed: " +
2298
- util.classString(didFulfill);
2299
- if (arguments.length > 1) {
2300
- msg += ", " + util.classString(didReject);
2301
- }
2302
- this._warn(msg);
2303
- }
2304
- return this._then(didFulfill, didReject, didProgress,
2305
- undefined, undefined);
2306
- };
2307
-
2308
- Promise.prototype.done = function (didFulfill, didReject, didProgress) {
2309
- var promise = this._then(didFulfill, didReject, didProgress,
2310
- undefined, undefined);
2311
- promise._setIsFinal();
2312
- };
2313
-
2314
- Promise.prototype.spread = function (didFulfill, didReject) {
2315
- return this.all()._then(didFulfill, didReject, undefined, APPLY, undefined);
2316
- };
2317
-
2318
- Promise.prototype.isCancellable = function () {
2319
- return !this.isResolved() &&
2320
- this._cancellable();
2321
- };
2322
-
2323
- Promise.prototype.toJSON = function () {
2324
- var ret = {
2325
- isFulfilled: false,
2326
- isRejected: false,
2327
- fulfillmentValue: undefined,
2328
- rejectionReason: undefined
2329
- };
2330
- if (this.isFulfilled()) {
2331
- ret.fulfillmentValue = this.value();
2332
- ret.isFulfilled = true;
2333
- } else if (this.isRejected()) {
2334
- ret.rejectionReason = this.reason();
2335
- ret.isRejected = true;
2336
- }
2337
- return ret;
2338
- };
2339
-
2340
- Promise.prototype.all = function () {
2341
- return new PromiseArray(this).promise();
2342
- };
2343
-
2344
- Promise.prototype.error = function (fn) {
2345
- return this.caught(util.originatesFromRejection, fn);
2346
- };
2347
-
2348
- Promise.getNewLibraryCopy = module.exports;
2349
-
2350
- Promise.is = function (val) {
2351
- return val instanceof Promise;
2352
- };
2353
-
2354
- Promise.fromNode = function(fn) {
2355
- var ret = new Promise(INTERNAL);
2356
- var result = tryCatch(fn)(nodebackForPromise(ret));
2357
- if (result === errorObj) {
2358
- ret._rejectCallback(result.e, true, true);
2359
- }
2360
- return ret;
2361
- };
2362
-
2363
- Promise.all = function (promises) {
2364
- return new PromiseArray(promises).promise();
2365
- };
2366
-
2367
- Promise.defer = Promise.pending = function () {
2368
- var promise = new Promise(INTERNAL);
2369
- return new PromiseResolver(promise);
2370
- };
2371
-
2372
- Promise.cast = function (obj) {
2373
- var ret = tryConvertToPromise(obj);
2374
- if (!(ret instanceof Promise)) {
2375
- var val = ret;
2376
- ret = new Promise(INTERNAL);
2377
- ret._fulfillUnchecked(val);
2378
- }
2379
- return ret;
2380
- };
2381
-
2382
- Promise.resolve = Promise.fulfilled = Promise.cast;
2383
-
2384
- Promise.reject = Promise.rejected = function (reason) {
2385
- var ret = new Promise(INTERNAL);
2386
- ret._captureStackTrace();
2387
- ret._rejectCallback(reason, true);
2388
- return ret;
2389
- };
2390
-
2391
- Promise.setScheduler = function(fn) {
2392
- if (typeof fn !== "function") throw new TypeError("fn must be a function\u000a\u000a See http://goo.gl/916lJJ\u000a");
2393
- var prev = async._schedule;
2394
- async._schedule = fn;
2395
- return prev;
2396
- };
2397
-
2398
- Promise.prototype._then = function (
2399
- didFulfill,
2400
- didReject,
2401
- didProgress,
2402
- receiver,
2403
- internalData
2404
- ) {
2405
- var haveInternalData = internalData !== undefined;
2406
- var ret = haveInternalData ? internalData : new Promise(INTERNAL);
2407
-
2408
- if (!haveInternalData) {
2409
- ret._propagateFrom(this, 4 | 1);
2410
- ret._captureStackTrace();
2411
- }
2412
-
2413
- var target = this._target();
2414
- if (target !== this) {
2415
- if (receiver === undefined) receiver = this._boundTo;
2416
- if (!haveInternalData) ret._setIsMigrated();
2417
- }
2418
-
2419
- var callbackIndex = target._addCallbacks(didFulfill,
2420
- didReject,
2421
- didProgress,
2422
- ret,
2423
- receiver,
2424
- getDomain());
2425
-
2426
- if (target._isResolved() && !target._isSettlePromisesQueued()) {
2427
- async.invoke(
2428
- target._settlePromiseAtPostResolution, target, callbackIndex);
2429
- }
2430
-
2431
- return ret;
2432
- };
2433
-
2434
- Promise.prototype._settlePromiseAtPostResolution = function (index) {
2435
- if (this._isRejectionUnhandled()) this._unsetRejectionIsUnhandled();
2436
- this._settlePromiseAt(index);
2437
- };
2438
-
2439
- Promise.prototype._length = function () {
2440
- return this._bitField & 131071;
2441
- };
2442
-
2443
- Promise.prototype._isFollowingOrFulfilledOrRejected = function () {
2444
- return (this._bitField & 939524096) > 0;
2445
- };
2446
-
2447
- Promise.prototype._isFollowing = function () {
2448
- return (this._bitField & 536870912) === 536870912;
2449
- };
2450
-
2451
- Promise.prototype._setLength = function (len) {
2452
- this._bitField = (this._bitField & -131072) |
2453
- (len & 131071);
2454
- };
2455
-
2456
- Promise.prototype._setFulfilled = function () {
2457
- this._bitField = this._bitField | 268435456;
2458
- };
2459
-
2460
- Promise.prototype._setRejected = function () {
2461
- this._bitField = this._bitField | 134217728;
2462
- };
2463
-
2464
- Promise.prototype._setFollowing = function () {
2465
- this._bitField = this._bitField | 536870912;
2466
- };
2467
-
2468
- Promise.prototype._setIsFinal = function () {
2469
- this._bitField = this._bitField | 33554432;
2470
- };
2471
-
2472
- Promise.prototype._isFinal = function () {
2473
- return (this._bitField & 33554432) > 0;
2474
- };
2475
-
2476
- Promise.prototype._cancellable = function () {
2477
- return (this._bitField & 67108864) > 0;
2478
- };
2479
-
2480
- Promise.prototype._setCancellable = function () {
2481
- this._bitField = this._bitField | 67108864;
2482
- };
2483
-
2484
- Promise.prototype._unsetCancellable = function () {
2485
- this._bitField = this._bitField & (~67108864);
2486
- };
2487
-
2488
- Promise.prototype._setIsMigrated = function () {
2489
- this._bitField = this._bitField | 4194304;
2490
- };
2491
-
2492
- Promise.prototype._unsetIsMigrated = function () {
2493
- this._bitField = this._bitField & (~4194304);
2494
- };
2495
-
2496
- Promise.prototype._isMigrated = function () {
2497
- return (this._bitField & 4194304) > 0;
2498
- };
2499
-
2500
- Promise.prototype._receiverAt = function (index) {
2501
- var ret = index === 0
2502
- ? this._receiver0
2503
- : this[
2504
- index * 5 - 5 + 4];
2505
- if (ret === UNDEFINED_BINDING) {
2506
- return undefined;
2507
- } else if (ret === undefined && this._isBound()) {
2508
- return this._boundValue();
2509
- }
2510
- return ret;
2511
- };
2512
-
2513
- Promise.prototype._promiseAt = function (index) {
2514
- return index === 0
2515
- ? this._promise0
2516
- : this[index * 5 - 5 + 3];
2517
- };
2518
-
2519
- Promise.prototype._fulfillmentHandlerAt = function (index) {
2520
- return index === 0
2521
- ? this._fulfillmentHandler0
2522
- : this[index * 5 - 5 + 0];
2523
- };
2524
-
2525
- Promise.prototype._rejectionHandlerAt = function (index) {
2526
- return index === 0
2527
- ? this._rejectionHandler0
2528
- : this[index * 5 - 5 + 1];
2529
- };
2530
-
2531
- Promise.prototype._boundValue = function() {
2532
- var ret = this._boundTo;
2533
- if (ret !== undefined) {
2534
- if (ret instanceof Promise) {
2535
- if (ret.isFulfilled()) {
2536
- return ret.value();
2537
- } else {
2538
- return undefined;
2539
- }
2540
- }
2541
- }
2542
- return ret;
2543
- };
2544
-
2545
- Promise.prototype._migrateCallbacks = function (follower, index) {
2546
- var fulfill = follower._fulfillmentHandlerAt(index);
2547
- var reject = follower._rejectionHandlerAt(index);
2548
- var progress = follower._progressHandlerAt(index);
2549
- var promise = follower._promiseAt(index);
2550
- var receiver = follower._receiverAt(index);
2551
- if (promise instanceof Promise) promise._setIsMigrated();
2552
- if (receiver === undefined) receiver = UNDEFINED_BINDING;
2553
- this._addCallbacks(fulfill, reject, progress, promise, receiver, null);
2554
- };
2555
-
2556
- Promise.prototype._addCallbacks = function (
2557
- fulfill,
2558
- reject,
2559
- progress,
2560
- promise,
2561
- receiver,
2562
- domain
2563
- ) {
2564
- var index = this._length();
2565
-
2566
- if (index >= 131071 - 5) {
2567
- index = 0;
2568
- this._setLength(0);
2569
- }
2570
-
2571
- if (index === 0) {
2572
- this._promise0 = promise;
2573
- if (receiver !== undefined) this._receiver0 = receiver;
2574
- if (typeof fulfill === "function" && !this._isCarryingStackTrace()) {
2575
- this._fulfillmentHandler0 =
2576
- domain === null ? fulfill : domain.bind(fulfill);
2577
- }
2578
- if (typeof reject === "function") {
2579
- this._rejectionHandler0 =
2580
- domain === null ? reject : domain.bind(reject);
2581
- }
2582
- if (typeof progress === "function") {
2583
- this._progressHandler0 =
2584
- domain === null ? progress : domain.bind(progress);
2585
- }
2586
- } else {
2587
- var base = index * 5 - 5;
2588
- this[base + 3] = promise;
2589
- this[base + 4] = receiver;
2590
- if (typeof fulfill === "function") {
2591
- this[base + 0] =
2592
- domain === null ? fulfill : domain.bind(fulfill);
2593
- }
2594
- if (typeof reject === "function") {
2595
- this[base + 1] =
2596
- domain === null ? reject : domain.bind(reject);
2597
- }
2598
- if (typeof progress === "function") {
2599
- this[base + 2] =
2600
- domain === null ? progress : domain.bind(progress);
2601
- }
2602
- }
2603
- this._setLength(index + 1);
2604
- return index;
2605
- };
2606
-
2607
- Promise.prototype._setProxyHandlers = function (receiver, promiseSlotValue) {
2608
- var index = this._length();
2609
-
2610
- if (index >= 131071 - 5) {
2611
- index = 0;
2612
- this._setLength(0);
2613
- }
2614
- if (index === 0) {
2615
- this._promise0 = promiseSlotValue;
2616
- this._receiver0 = receiver;
2617
- } else {
2618
- var base = index * 5 - 5;
2619
- this[base + 3] = promiseSlotValue;
2620
- this[base + 4] = receiver;
2621
- }
2622
- this._setLength(index + 1);
2623
- };
2624
-
2625
- Promise.prototype._proxyPromiseArray = function (promiseArray, index) {
2626
- this._setProxyHandlers(promiseArray, index);
2627
- };
2628
-
2629
- Promise.prototype._resolveCallback = function(value, shouldBind) {
2630
- if (this._isFollowingOrFulfilledOrRejected()) return;
2631
- if (value === this)
2632
- return this._rejectCallback(makeSelfResolutionError(), false, true);
2633
- var maybePromise = tryConvertToPromise(value, this);
2634
- if (!(maybePromise instanceof Promise)) return this._fulfill(value);
2635
-
2636
- var propagationFlags = 1 | (shouldBind ? 4 : 0);
2637
- this._propagateFrom(maybePromise, propagationFlags);
2638
- var promise = maybePromise._target();
2639
- if (promise._isPending()) {
2640
- var len = this._length();
2641
- for (var i = 0; i < len; ++i) {
2642
- promise._migrateCallbacks(this, i);
2643
- }
2644
- this._setFollowing();
2645
- this._setLength(0);
2646
- this._setFollowee(promise);
2647
- } else if (promise._isFulfilled()) {
2648
- this._fulfillUnchecked(promise._value());
2649
- } else {
2650
- this._rejectUnchecked(promise._reason(),
2651
- promise._getCarriedStackTrace());
2652
- }
2653
- };
2654
-
2655
- Promise.prototype._rejectCallback =
2656
- function(reason, synchronous, shouldNotMarkOriginatingFromRejection) {
2657
- if (!shouldNotMarkOriginatingFromRejection) {
2658
- util.markAsOriginatingFromRejection(reason);
2659
- }
2660
- var trace = util.ensureErrorObject(reason);
2661
- var hasStack = trace === reason;
2662
- this._attachExtraTrace(trace, synchronous ? hasStack : false);
2663
- this._reject(reason, hasStack ? undefined : trace);
2664
- };
2665
-
2666
- Promise.prototype._resolveFromResolver = function (resolver) {
2667
- var promise = this;
2668
- this._captureStackTrace();
2669
- this._pushContext();
2670
- var synchronous = true;
2671
- var r = tryCatch(resolver)(function(value) {
2672
- if (promise === null) return;
2673
- promise._resolveCallback(value);
2674
- promise = null;
2675
- }, function (reason) {
2676
- if (promise === null) return;
2677
- promise._rejectCallback(reason, synchronous);
2678
- promise = null;
2679
- });
2680
- synchronous = false;
2681
- this._popContext();
2682
-
2683
- if (r !== undefined && r === errorObj && promise !== null) {
2684
- promise._rejectCallback(r.e, true, true);
2685
- promise = null;
2686
- }
2687
- };
2688
-
2689
- Promise.prototype._settlePromiseFromHandler = function (
2690
- handler, receiver, value, promise
2691
- ) {
2692
- if (promise._isRejected()) return;
2693
- promise._pushContext();
2694
- var x;
2695
- if (receiver === APPLY && !this._isRejected()) {
2696
- x = tryCatch(handler).apply(this._boundValue(), value);
2697
- } else {
2698
- x = tryCatch(handler).call(receiver, value);
2699
- }
2700
- promise._popContext();
2701
-
2702
- if (x === errorObj || x === promise || x === NEXT_FILTER) {
2703
- var err = x === promise ? makeSelfResolutionError() : x.e;
2704
- promise._rejectCallback(err, false, true);
2705
- } else {
2706
- promise._resolveCallback(x);
2707
- }
2708
- };
2709
-
2710
- Promise.prototype._target = function() {
2711
- var ret = this;
2712
- while (ret._isFollowing()) ret = ret._followee();
2713
- return ret;
2714
- };
2715
-
2716
- Promise.prototype._followee = function() {
2717
- return this._rejectionHandler0;
2718
- };
2719
-
2720
- Promise.prototype._setFollowee = function(promise) {
2721
- this._rejectionHandler0 = promise;
2722
- };
2723
-
2724
- Promise.prototype._cleanValues = function () {
2725
- if (this._cancellable()) {
2726
- this._cancellationParent = undefined;
2727
- }
2728
- };
2729
-
2730
- Promise.prototype._propagateFrom = function (parent, flags) {
2731
- if ((flags & 1) > 0 && parent._cancellable()) {
2732
- this._setCancellable();
2733
- this._cancellationParent = parent;
2734
- }
2735
- if ((flags & 4) > 0 && parent._isBound()) {
2736
- this._setBoundTo(parent._boundTo);
2737
- }
2738
- };
2739
-
2740
- Promise.prototype._fulfill = function (value) {
2741
- if (this._isFollowingOrFulfilledOrRejected()) return;
2742
- this._fulfillUnchecked(value);
2743
- };
2744
-
2745
- Promise.prototype._reject = function (reason, carriedStackTrace) {
2746
- if (this._isFollowingOrFulfilledOrRejected()) return;
2747
- this._rejectUnchecked(reason, carriedStackTrace);
2748
- };
2749
-
2750
- Promise.prototype._settlePromiseAt = function (index) {
2751
- var promise = this._promiseAt(index);
2752
- var isPromise = promise instanceof Promise;
2753
-
2754
- if (isPromise && promise._isMigrated()) {
2755
- promise._unsetIsMigrated();
2756
- return async.invoke(this._settlePromiseAt, this, index);
2757
- }
2758
- var handler = this._isFulfilled()
2759
- ? this._fulfillmentHandlerAt(index)
2760
- : this._rejectionHandlerAt(index);
2761
-
2762
- var carriedStackTrace =
2763
- this._isCarryingStackTrace() ? this._getCarriedStackTrace() : undefined;
2764
- var value = this._settledValue;
2765
- var receiver = this._receiverAt(index);
2766
- this._clearCallbackDataAtIndex(index);
2767
-
2768
- if (typeof handler === "function") {
2769
- if (!isPromise) {
2770
- handler.call(receiver, value, promise);
2771
- } else {
2772
- this._settlePromiseFromHandler(handler, receiver, value, promise);
2773
- }
2774
- } else if (receiver instanceof PromiseArray) {
2775
- if (!receiver._isResolved()) {
2776
- if (this._isFulfilled()) {
2777
- receiver._promiseFulfilled(value, promise);
2778
- }
2779
- else {
2780
- receiver._promiseRejected(value, promise);
2781
- }
2782
- }
2783
- } else if (isPromise) {
2784
- if (this._isFulfilled()) {
2785
- promise._fulfill(value);
2786
- } else {
2787
- promise._reject(value, carriedStackTrace);
2788
- }
2789
- }
2790
-
2791
- if (index >= 4 && (index & 31) === 4)
2792
- async.invokeLater(this._setLength, this, 0);
2793
- };
2794
-
2795
- Promise.prototype._clearCallbackDataAtIndex = function(index) {
2796
- if (index === 0) {
2797
- if (!this._isCarryingStackTrace()) {
2798
- this._fulfillmentHandler0 = undefined;
2799
- }
2800
- this._rejectionHandler0 =
2801
- this._progressHandler0 =
2802
- this._receiver0 =
2803
- this._promise0 = undefined;
2804
- } else {
2805
- var base = index * 5 - 5;
2806
- this[base + 3] =
2807
- this[base + 4] =
2808
- this[base + 0] =
2809
- this[base + 1] =
2810
- this[base + 2] = undefined;
2811
- }
2812
- };
2813
-
2814
- Promise.prototype._isSettlePromisesQueued = function () {
2815
- return (this._bitField &
2816
- -1073741824) === -1073741824;
2817
- };
2818
-
2819
- Promise.prototype._setSettlePromisesQueued = function () {
2820
- this._bitField = this._bitField | -1073741824;
2821
- };
2822
-
2823
- Promise.prototype._unsetSettlePromisesQueued = function () {
2824
- this._bitField = this._bitField & (~-1073741824);
2825
- };
2826
-
2827
- Promise.prototype._queueSettlePromises = function() {
2828
- async.settlePromises(this);
2829
- this._setSettlePromisesQueued();
2830
- };
2831
-
2832
- Promise.prototype._fulfillUnchecked = function (value) {
2833
- if (value === this) {
2834
- var err = makeSelfResolutionError();
2835
- this._attachExtraTrace(err);
2836
- return this._rejectUnchecked(err, undefined);
2837
- }
2838
- this._setFulfilled();
2839
- this._settledValue = value;
2840
- this._cleanValues();
2841
-
2842
- if (this._length() > 0) {
2843
- this._queueSettlePromises();
2844
- }
2845
- };
2846
-
2847
- Promise.prototype._rejectUncheckedCheckError = function (reason) {
2848
- var trace = util.ensureErrorObject(reason);
2849
- this._rejectUnchecked(reason, trace === reason ? undefined : trace);
2850
- };
2851
-
2852
- Promise.prototype._rejectUnchecked = function (reason, trace) {
2853
- if (reason === this) {
2854
- var err = makeSelfResolutionError();
2855
- this._attachExtraTrace(err);
2856
- return this._rejectUnchecked(err);
2857
- }
2858
- this._setRejected();
2859
- this._settledValue = reason;
2860
- this._cleanValues();
2861
-
2862
- if (this._isFinal()) {
2863
- async.throwLater(function(e) {
2864
- if ("stack" in e) {
2865
- async.invokeFirst(
2866
- CapturedTrace.unhandledRejection, undefined, e);
2867
- }
2868
- throw e;
2869
- }, trace === undefined ? reason : trace);
2870
- return;
2871
- }
2872
-
2873
- if (trace !== undefined && trace !== reason) {
2874
- this._setCarriedStackTrace(trace);
2875
- }
2876
-
2877
- if (this._length() > 0) {
2878
- this._queueSettlePromises();
2879
- } else {
2880
- this._ensurePossibleRejectionHandled();
2881
- }
2882
- };
2883
-
2884
- Promise.prototype._settlePromises = function () {
2885
- this._unsetSettlePromisesQueued();
2886
- var len = this._length();
2887
- for (var i = 0; i < len; i++) {
2888
- this._settlePromiseAt(i);
2889
- }
2890
- };
2891
-
2892
-
2893
- util.notEnumerableProp(Promise,
2894
- "_makeSelfResolutionError",
2895
- makeSelfResolutionError);
2896
-
2897
- _dereq_("./progress.js")(Promise, PromiseArray);
2898
- _dereq_("./method.js")(Promise, INTERNAL, tryConvertToPromise, apiRejection);
2899
- _dereq_("./bind.js")(Promise, INTERNAL, tryConvertToPromise);
2900
- _dereq_("./finally.js")(Promise, NEXT_FILTER, tryConvertToPromise);
2901
- _dereq_("./direct_resolve.js")(Promise);
2902
- _dereq_("./synchronous_inspection.js")(Promise);
2903
- _dereq_("./join.js")(Promise, PromiseArray, tryConvertToPromise, INTERNAL);
2904
- Promise.version = "2.11.0";
2905
- Promise.Promise = Promise;
2906
- _dereq_('./map.js')(Promise, PromiseArray, apiRejection, tryConvertToPromise, INTERNAL);
2907
- _dereq_('./cancel.js')(Promise);
2908
- _dereq_('./using.js')(Promise, apiRejection, tryConvertToPromise, createContext);
2909
- _dereq_('./generators.js')(Promise, apiRejection, INTERNAL, tryConvertToPromise);
2910
- _dereq_('./nodeify.js')(Promise);
2911
- _dereq_('./call_get.js')(Promise);
2912
- _dereq_('./props.js')(Promise, PromiseArray, tryConvertToPromise, apiRejection);
2913
- _dereq_('./race.js')(Promise, INTERNAL, tryConvertToPromise, apiRejection);
2914
- _dereq_('./reduce.js')(Promise, PromiseArray, apiRejection, tryConvertToPromise, INTERNAL);
2915
- _dereq_('./settle.js')(Promise, PromiseArray);
2916
- _dereq_('./some.js')(Promise, PromiseArray, apiRejection);
2917
- _dereq_('./promisify.js')(Promise, INTERNAL);
2918
- _dereq_('./any.js')(Promise);
2919
- _dereq_('./each.js')(Promise, INTERNAL);
2920
- _dereq_('./timers.js')(Promise, INTERNAL);
2921
- _dereq_('./filter.js')(Promise, INTERNAL);
2922
-
2923
- util.toFastProperties(Promise);
2924
- util.toFastProperties(Promise.prototype);
2925
- function fillTypes(value) {
2926
- var p = new Promise(INTERNAL);
2927
- p._fulfillmentHandler0 = value;
2928
- p._rejectionHandler0 = value;
2929
- p._progressHandler0 = value;
2930
- p._promise0 = value;
2931
- p._receiver0 = value;
2932
- p._settledValue = value;
2933
- }
2934
- // Complete slack tracking, opt out of field-type tracking and
2935
- // stabilize map
2936
- fillTypes({a: 1});
2937
- fillTypes({b: 2});
2938
- fillTypes({c: 3});
2939
- fillTypes(1);
2940
- fillTypes(function(){});
2941
- fillTypes(undefined);
2942
- fillTypes(false);
2943
- fillTypes(new Promise(INTERNAL));
2944
- CapturedTrace.setBounds(async.firstLineError, util.lastLineError);
2945
- return Promise;
2946
-
2947
- };
2948
-
2949
- },{"./any.js":1,"./async.js":2,"./bind.js":3,"./call_get.js":5,"./cancel.js":6,"./captured_trace.js":7,"./catch_filter.js":8,"./context.js":9,"./debuggability.js":10,"./direct_resolve.js":11,"./each.js":12,"./errors.js":13,"./filter.js":15,"./finally.js":16,"./generators.js":17,"./join.js":18,"./map.js":19,"./method.js":20,"./nodeify.js":21,"./progress.js":22,"./promise_array.js":24,"./promise_resolver.js":25,"./promisify.js":26,"./props.js":27,"./race.js":29,"./reduce.js":30,"./settle.js":32,"./some.js":33,"./synchronous_inspection.js":34,"./thenables.js":35,"./timers.js":36,"./using.js":37,"./util.js":38}],24:[function(_dereq_,module,exports){
2950
- "use strict";
2951
- module.exports = function(Promise, INTERNAL, tryConvertToPromise,
2952
- apiRejection) {
2953
- var util = _dereq_("./util.js");
2954
- var isArray = util.isArray;
2955
-
2956
- function toResolutionValue(val) {
2957
- switch(val) {
2958
- case -2: return [];
2959
- case -3: return {};
2960
- }
2961
- }
2962
-
2963
- function PromiseArray(values) {
2964
- var promise = this._promise = new Promise(INTERNAL);
2965
- var parent;
2966
- if (values instanceof Promise) {
2967
- parent = values;
2968
- promise._propagateFrom(parent, 1 | 4);
2969
- }
2970
- this._values = values;
2971
- this._length = 0;
2972
- this._totalResolved = 0;
2973
- this._init(undefined, -2);
2974
- }
2975
- PromiseArray.prototype.length = function () {
2976
- return this._length;
2977
- };
2978
-
2979
- PromiseArray.prototype.promise = function () {
2980
- return this._promise;
2981
- };
2982
-
2983
- PromiseArray.prototype._init = function init(_, resolveValueIfEmpty) {
2984
- var values = tryConvertToPromise(this._values, this._promise);
2985
- if (values instanceof Promise) {
2986
- values = values._target();
2987
- this._values = values;
2988
- if (values._isFulfilled()) {
2989
- values = values._value();
2990
- if (!isArray(values)) {
2991
- var err = new Promise.TypeError("expecting an array, a promise or a thenable\u000a\u000a See http://goo.gl/s8MMhc\u000a");
2992
- this.__hardReject__(err);
2993
- return;
2994
- }
2995
- } else if (values._isPending()) {
2996
- values._then(
2997
- init,
2998
- this._reject,
2999
- undefined,
3000
- this,
3001
- resolveValueIfEmpty
3002
- );
3003
- return;
3004
- } else {
3005
- this._reject(values._reason());
3006
- return;
3007
- }
3008
- } else if (!isArray(values)) {
3009
- this._promise._reject(apiRejection("expecting an array, a promise or a thenable\u000a\u000a See http://goo.gl/s8MMhc\u000a")._reason());
3010
- return;
3011
- }
3012
-
3013
- if (values.length === 0) {
3014
- if (resolveValueIfEmpty === -5) {
3015
- this._resolveEmptyArray();
3016
- }
3017
- else {
3018
- this._resolve(toResolutionValue(resolveValueIfEmpty));
3019
- }
3020
- return;
3021
- }
3022
- var len = this.getActualLength(values.length);
3023
- this._length = len;
3024
- this._values = this.shouldCopyValues() ? new Array(len) : this._values;
3025
- var promise = this._promise;
3026
- for (var i = 0; i < len; ++i) {
3027
- var isResolved = this._isResolved();
3028
- var maybePromise = tryConvertToPromise(values[i], promise);
3029
- if (maybePromise instanceof Promise) {
3030
- maybePromise = maybePromise._target();
3031
- if (isResolved) {
3032
- maybePromise._ignoreRejections();
3033
- } else if (maybePromise._isPending()) {
3034
- maybePromise._proxyPromiseArray(this, i);
3035
- } else if (maybePromise._isFulfilled()) {
3036
- this._promiseFulfilled(maybePromise._value(), i);
3037
- } else {
3038
- this._promiseRejected(maybePromise._reason(), i);
3039
- }
3040
- } else if (!isResolved) {
3041
- this._promiseFulfilled(maybePromise, i);
3042
- }
3043
- }
3044
- };
3045
-
3046
- PromiseArray.prototype._isResolved = function () {
3047
- return this._values === null;
3048
- };
3049
-
3050
- PromiseArray.prototype._resolve = function (value) {
3051
- this._values = null;
3052
- this._promise._fulfill(value);
3053
- };
3054
-
3055
- PromiseArray.prototype.__hardReject__ =
3056
- PromiseArray.prototype._reject = function (reason) {
3057
- this._values = null;
3058
- this._promise._rejectCallback(reason, false, true);
3059
- };
3060
-
3061
- PromiseArray.prototype._promiseProgressed = function (progressValue, index) {
3062
- this._promise._progress({
3063
- index: index,
3064
- value: progressValue
3065
- });
3066
- };
3067
-
3068
-
3069
- PromiseArray.prototype._promiseFulfilled = function (value, index) {
3070
- this._values[index] = value;
3071
- var totalResolved = ++this._totalResolved;
3072
- if (totalResolved >= this._length) {
3073
- this._resolve(this._values);
3074
- }
3075
- };
3076
-
3077
- PromiseArray.prototype._promiseRejected = function (reason, index) {
3078
- this._totalResolved++;
3079
- this._reject(reason);
3080
- };
3081
-
3082
- PromiseArray.prototype.shouldCopyValues = function () {
3083
- return true;
3084
- };
3085
-
3086
- PromiseArray.prototype.getActualLength = function (len) {
3087
- return len;
3088
- };
3089
-
3090
- return PromiseArray;
3091
- };
3092
-
3093
- },{"./util.js":38}],25:[function(_dereq_,module,exports){
3094
- "use strict";
3095
- var util = _dereq_("./util.js");
3096
- var maybeWrapAsError = util.maybeWrapAsError;
3097
- var errors = _dereq_("./errors.js");
3098
- var TimeoutError = errors.TimeoutError;
3099
- var OperationalError = errors.OperationalError;
3100
- var haveGetters = util.haveGetters;
3101
- var es5 = _dereq_("./es5.js");
3102
-
3103
- function isUntypedError(obj) {
3104
- return obj instanceof Error &&
3105
- es5.getPrototypeOf(obj) === Error.prototype;
3106
- }
3107
-
3108
- var rErrorKey = /^(?:name|message|stack|cause)$/;
3109
- function wrapAsOperationalError(obj) {
3110
- var ret;
3111
- if (isUntypedError(obj)) {
3112
- ret = new OperationalError(obj);
3113
- ret.name = obj.name;
3114
- ret.message = obj.message;
3115
- ret.stack = obj.stack;
3116
- var keys = es5.keys(obj);
3117
- for (var i = 0; i < keys.length; ++i) {
3118
- var key = keys[i];
3119
- if (!rErrorKey.test(key)) {
3120
- ret[key] = obj[key];
3121
- }
3122
- }
3123
- return ret;
3124
- }
3125
- util.markAsOriginatingFromRejection(obj);
3126
- return obj;
3127
- }
3128
-
3129
- function nodebackForPromise(promise) {
3130
- return function(err, value) {
3131
- if (promise === null) return;
3132
-
3133
- if (err) {
3134
- var wrapped = wrapAsOperationalError(maybeWrapAsError(err));
3135
- promise._attachExtraTrace(wrapped);
3136
- promise._reject(wrapped);
3137
- } else if (arguments.length > 2) {
3138
- var $_len = arguments.length;var args = new Array($_len - 1); for(var $_i = 1; $_i < $_len; ++$_i) {args[$_i - 1] = arguments[$_i];}
3139
- promise._fulfill(args);
3140
- } else {
3141
- promise._fulfill(value);
3142
- }
3143
-
3144
- promise = null;
3145
- };
3146
- }
3147
-
3148
-
3149
- var PromiseResolver;
3150
- if (!haveGetters) {
3151
- PromiseResolver = function (promise) {
3152
- this.promise = promise;
3153
- this.asCallback = nodebackForPromise(promise);
3154
- this.callback = this.asCallback;
3155
- };
3156
- }
3157
- else {
3158
- PromiseResolver = function (promise) {
3159
- this.promise = promise;
3160
- };
3161
- }
3162
- if (haveGetters) {
3163
- var prop = {
3164
- get: function() {
3165
- return nodebackForPromise(this.promise);
3166
- }
3167
- };
3168
- es5.defineProperty(PromiseResolver.prototype, "asCallback", prop);
3169
- es5.defineProperty(PromiseResolver.prototype, "callback", prop);
3170
- }
3171
-
3172
- PromiseResolver._nodebackForPromise = nodebackForPromise;
3173
-
3174
- PromiseResolver.prototype.toString = function () {
3175
- return "[object PromiseResolver]";
3176
- };
3177
-
3178
- PromiseResolver.prototype.resolve =
3179
- PromiseResolver.prototype.fulfill = function (value) {
3180
- if (!(this instanceof PromiseResolver)) {
3181
- throw new TypeError("Illegal invocation, resolver resolve/reject must be called within a resolver context. Consider using the promise constructor instead.\u000a\u000a See http://goo.gl/sdkXL9\u000a");
3182
- }
3183
- this.promise._resolveCallback(value);
3184
- };
3185
-
3186
- PromiseResolver.prototype.reject = function (reason) {
3187
- if (!(this instanceof PromiseResolver)) {
3188
- throw new TypeError("Illegal invocation, resolver resolve/reject must be called within a resolver context. Consider using the promise constructor instead.\u000a\u000a See http://goo.gl/sdkXL9\u000a");
3189
- }
3190
- this.promise._rejectCallback(reason);
3191
- };
3192
-
3193
- PromiseResolver.prototype.progress = function (value) {
3194
- if (!(this instanceof PromiseResolver)) {
3195
- throw new TypeError("Illegal invocation, resolver resolve/reject must be called within a resolver context. Consider using the promise constructor instead.\u000a\u000a See http://goo.gl/sdkXL9\u000a");
3196
- }
3197
- this.promise._progress(value);
3198
- };
3199
-
3200
- PromiseResolver.prototype.cancel = function (err) {
3201
- this.promise.cancel(err);
3202
- };
3203
-
3204
- PromiseResolver.prototype.timeout = function () {
3205
- this.reject(new TimeoutError("timeout"));
3206
- };
3207
-
3208
- PromiseResolver.prototype.isResolved = function () {
3209
- return this.promise.isResolved();
3210
- };
3211
-
3212
- PromiseResolver.prototype.toJSON = function () {
3213
- return this.promise.toJSON();
3214
- };
3215
-
3216
- module.exports = PromiseResolver;
3217
-
3218
- },{"./errors.js":13,"./es5.js":14,"./util.js":38}],26:[function(_dereq_,module,exports){
3219
- "use strict";
3220
- module.exports = function(Promise, INTERNAL) {
3221
- var THIS = {};
3222
- var util = _dereq_("./util.js");
3223
- var nodebackForPromise = _dereq_("./promise_resolver.js")
3224
- ._nodebackForPromise;
3225
- var withAppended = util.withAppended;
3226
- var maybeWrapAsError = util.maybeWrapAsError;
3227
- var canEvaluate = util.canEvaluate;
3228
- var TypeError = _dereq_("./errors").TypeError;
3229
- var defaultSuffix = "Async";
3230
- var defaultPromisified = {__isPromisified__: true};
3231
- var noCopyProps = [
3232
- "arity", "length",
3233
- "name",
3234
- "arguments",
3235
- "caller",
3236
- "callee",
3237
- "prototype",
3238
- "__isPromisified__"
3239
- ];
3240
- var noCopyPropsPattern = new RegExp("^(?:" + noCopyProps.join("|") + ")$");
3241
-
3242
- var defaultFilter = function(name) {
3243
- return util.isIdentifier(name) &&
3244
- name.charAt(0) !== "_" &&
3245
- name !== "constructor";
3246
- };
3247
-
3248
- function propsFilter(key) {
3249
- return !noCopyPropsPattern.test(key);
3250
- }
3251
-
3252
- function isPromisified(fn) {
3253
- try {
3254
- return fn.__isPromisified__ === true;
3255
- }
3256
- catch (e) {
3257
- return false;
3258
- }
3259
- }
3260
-
3261
- function hasPromisified(obj, key, suffix) {
3262
- var val = util.getDataPropertyOrDefault(obj, key + suffix,
3263
- defaultPromisified);
3264
- return val ? isPromisified(val) : false;
3265
- }
3266
- function checkValid(ret, suffix, suffixRegexp) {
3267
- for (var i = 0; i < ret.length; i += 2) {
3268
- var key = ret[i];
3269
- if (suffixRegexp.test(key)) {
3270
- var keyWithoutAsyncSuffix = key.replace(suffixRegexp, "");
3271
- for (var j = 0; j < ret.length; j += 2) {
3272
- if (ret[j] === keyWithoutAsyncSuffix) {
3273
- throw new TypeError("Cannot promisify an API that has normal methods with '%s'-suffix\u000a\u000a See http://goo.gl/iWrZbw\u000a"
3274
- .replace("%s", suffix));
3275
- }
3276
- }
3277
- }
3278
- }
3279
- }
3280
-
3281
- function promisifiableMethods(obj, suffix, suffixRegexp, filter) {
3282
- var keys = util.inheritedDataKeys(obj);
3283
- var ret = [];
3284
- for (var i = 0; i < keys.length; ++i) {
3285
- var key = keys[i];
3286
- var value = obj[key];
3287
- var passesDefaultFilter = filter === defaultFilter
3288
- ? true : defaultFilter(key, value, obj);
3289
- if (typeof value === "function" &&
3290
- !isPromisified(value) &&
3291
- !hasPromisified(obj, key, suffix) &&
3292
- filter(key, value, obj, passesDefaultFilter)) {
3293
- ret.push(key, value);
3294
- }
3295
- }
3296
- checkValid(ret, suffix, suffixRegexp);
3297
- return ret;
3298
- }
3299
-
3300
- var escapeIdentRegex = function(str) {
3301
- return str.replace(/([$])/, "\\$");
3302
- };
3303
-
3304
- var makeNodePromisifiedEval;
3305
- if (!true) {
3306
- var switchCaseArgumentOrder = function(likelyArgumentCount) {
3307
- var ret = [likelyArgumentCount];
3308
- var min = Math.max(0, likelyArgumentCount - 1 - 3);
3309
- for(var i = likelyArgumentCount - 1; i >= min; --i) {
3310
- ret.push(i);
3311
- }
3312
- for(var i = likelyArgumentCount + 1; i <= 3; ++i) {
3313
- ret.push(i);
3314
- }
3315
- return ret;
3316
- };
3317
-
3318
- var argumentSequence = function(argumentCount) {
3319
- return util.filledRange(argumentCount, "_arg", "");
3320
- };
3321
-
3322
- var parameterDeclaration = function(parameterCount) {
3323
- return util.filledRange(
3324
- Math.max(parameterCount, 3), "_arg", "");
3325
- };
3326
-
3327
- var parameterCount = function(fn) {
3328
- if (typeof fn.length === "number") {
3329
- return Math.max(Math.min(fn.length, 1023 + 1), 0);
3330
- }
3331
- return 0;
3332
- };
3333
-
3334
- makeNodePromisifiedEval =
3335
- function(callback, receiver, originalName, fn) {
3336
- var newParameterCount = Math.max(0, parameterCount(fn) - 1);
3337
- var argumentOrder = switchCaseArgumentOrder(newParameterCount);
3338
- var shouldProxyThis = typeof callback === "string" || receiver === THIS;
3339
-
3340
- function generateCallForArgumentCount(count) {
3341
- var args = argumentSequence(count).join(", ");
3342
- var comma = count > 0 ? ", " : "";
3343
- var ret;
3344
- if (shouldProxyThis) {
3345
- ret = "ret = callback.call(this, {{args}}, nodeback); break;\n";
3346
- } else {
3347
- ret = receiver === undefined
3348
- ? "ret = callback({{args}}, nodeback); break;\n"
3349
- : "ret = callback.call(receiver, {{args}}, nodeback); break;\n";
3350
- }
3351
- return ret.replace("{{args}}", args).replace(", ", comma);
3352
- }
3353
-
3354
- function generateArgumentSwitchCase() {
3355
- var ret = "";
3356
- for (var i = 0; i < argumentOrder.length; ++i) {
3357
- ret += "case " + argumentOrder[i] +":" +
3358
- generateCallForArgumentCount(argumentOrder[i]);
3359
- }
3360
-
3361
- ret += " \n\
3362
- default: \n\
3363
- var args = new Array(len + 1); \n\
3364
- var i = 0; \n\
3365
- for (var i = 0; i < len; ++i) { \n\
3366
- args[i] = arguments[i]; \n\
3367
- } \n\
3368
- args[i] = nodeback; \n\
3369
- [CodeForCall] \n\
3370
- break; \n\
3371
- ".replace("[CodeForCall]", (shouldProxyThis
3372
- ? "ret = callback.apply(this, args);\n"
3373
- : "ret = callback.apply(receiver, args);\n"));
3374
- return ret;
3375
- }
3376
-
3377
- var getFunctionCode = typeof callback === "string"
3378
- ? ("this != null ? this['"+callback+"'] : fn")
3379
- : "fn";
3380
-
3381
- return new Function("Promise",
3382
- "fn",
3383
- "receiver",
3384
- "withAppended",
3385
- "maybeWrapAsError",
3386
- "nodebackForPromise",
3387
- "tryCatch",
3388
- "errorObj",
3389
- "notEnumerableProp",
3390
- "INTERNAL","'use strict'; \n\
3391
- var ret = function (Parameters) { \n\
3392
- 'use strict'; \n\
3393
- var len = arguments.length; \n\
3394
- var promise = new Promise(INTERNAL); \n\
3395
- promise._captureStackTrace(); \n\
3396
- var nodeback = nodebackForPromise(promise); \n\
3397
- var ret; \n\
3398
- var callback = tryCatch([GetFunctionCode]); \n\
3399
- switch(len) { \n\
3400
- [CodeForSwitchCase] \n\
3401
- } \n\
3402
- if (ret === errorObj) { \n\
3403
- promise._rejectCallback(maybeWrapAsError(ret.e), true, true);\n\
3404
- } \n\
3405
- return promise; \n\
3406
- }; \n\
3407
- notEnumerableProp(ret, '__isPromisified__', true); \n\
3408
- return ret; \n\
3409
- "
3410
- .replace("Parameters", parameterDeclaration(newParameterCount))
3411
- .replace("[CodeForSwitchCase]", generateArgumentSwitchCase())
3412
- .replace("[GetFunctionCode]", getFunctionCode))(
3413
- Promise,
3414
- fn,
3415
- receiver,
3416
- withAppended,
3417
- maybeWrapAsError,
3418
- nodebackForPromise,
3419
- util.tryCatch,
3420
- util.errorObj,
3421
- util.notEnumerableProp,
3422
- INTERNAL
3423
- );
3424
- };
3425
- }
3426
-
3427
- function makeNodePromisifiedClosure(callback, receiver, _, fn) {
3428
- var defaultThis = (function() {return this;})();
3429
- var method = callback;
3430
- if (typeof method === "string") {
3431
- callback = fn;
3432
- }
3433
- function promisified() {
3434
- var _receiver = receiver;
3435
- if (receiver === THIS) _receiver = this;
3436
- var promise = new Promise(INTERNAL);
3437
- promise._captureStackTrace();
3438
- var cb = typeof method === "string" && this !== defaultThis
3439
- ? this[method] : callback;
3440
- var fn = nodebackForPromise(promise);
3441
- try {
3442
- cb.apply(_receiver, withAppended(arguments, fn));
3443
- } catch(e) {
3444
- promise._rejectCallback(maybeWrapAsError(e), true, true);
3445
- }
3446
- return promise;
3447
- }
3448
- util.notEnumerableProp(promisified, "__isPromisified__", true);
3449
- return promisified;
3450
- }
3451
-
3452
- var makeNodePromisified = canEvaluate
3453
- ? makeNodePromisifiedEval
3454
- : makeNodePromisifiedClosure;
3455
-
3456
- function promisifyAll(obj, suffix, filter, promisifier) {
3457
- var suffixRegexp = new RegExp(escapeIdentRegex(suffix) + "$");
3458
- var methods =
3459
- promisifiableMethods(obj, suffix, suffixRegexp, filter);
3460
-
3461
- for (var i = 0, len = methods.length; i < len; i+= 2) {
3462
- var key = methods[i];
3463
- var fn = methods[i+1];
3464
- var promisifiedKey = key + suffix;
3465
- if (promisifier === makeNodePromisified) {
3466
- obj[promisifiedKey] =
3467
- makeNodePromisified(key, THIS, key, fn, suffix);
3468
- } else {
3469
- var promisified = promisifier(fn, function() {
3470
- return makeNodePromisified(key, THIS, key, fn, suffix);
3471
- });
3472
- util.notEnumerableProp(promisified, "__isPromisified__", true);
3473
- obj[promisifiedKey] = promisified;
3474
- }
3475
- }
3476
- util.toFastProperties(obj);
3477
- return obj;
3478
- }
3479
-
3480
- function promisify(callback, receiver) {
3481
- return makeNodePromisified(callback, receiver, undefined, callback);
3482
- }
3483
-
3484
- Promise.promisify = function (fn, receiver) {
3485
- if (typeof fn !== "function") {
3486
- throw new TypeError("fn must be a function\u000a\u000a See http://goo.gl/916lJJ\u000a");
3487
- }
3488
- if (isPromisified(fn)) {
3489
- return fn;
3490
- }
3491
- var ret = promisify(fn, arguments.length < 2 ? THIS : receiver);
3492
- util.copyDescriptors(fn, ret, propsFilter);
3493
- return ret;
3494
- };
3495
-
3496
- Promise.promisifyAll = function (target, options) {
3497
- if (typeof target !== "function" && typeof target !== "object") {
3498
- throw new TypeError("the target of promisifyAll must be an object or a function\u000a\u000a See http://goo.gl/9ITlV0\u000a");
3499
- }
3500
- options = Object(options);
3501
- var suffix = options.suffix;
3502
- if (typeof suffix !== "string") suffix = defaultSuffix;
3503
- var filter = options.filter;
3504
- if (typeof filter !== "function") filter = defaultFilter;
3505
- var promisifier = options.promisifier;
3506
- if (typeof promisifier !== "function") promisifier = makeNodePromisified;
3507
-
3508
- if (!util.isIdentifier(suffix)) {
3509
- throw new RangeError("suffix must be a valid identifier\u000a\u000a See http://goo.gl/8FZo5V\u000a");
3510
- }
3511
-
3512
- var keys = util.inheritedDataKeys(target);
3513
- for (var i = 0; i < keys.length; ++i) {
3514
- var value = target[keys[i]];
3515
- if (keys[i] !== "constructor" &&
3516
- util.isClass(value)) {
3517
- promisifyAll(value.prototype, suffix, filter, promisifier);
3518
- promisifyAll(value, suffix, filter, promisifier);
3519
- }
3520
- }
3521
-
3522
- return promisifyAll(target, suffix, filter, promisifier);
3523
- };
3524
- };
3525
-
3526
-
3527
- },{"./errors":13,"./promise_resolver.js":25,"./util.js":38}],27:[function(_dereq_,module,exports){
3528
- "use strict";
3529
- module.exports = function(
3530
- Promise, PromiseArray, tryConvertToPromise, apiRejection) {
3531
- var util = _dereq_("./util.js");
3532
- var isObject = util.isObject;
3533
- var es5 = _dereq_("./es5.js");
3534
-
3535
- function PropertiesPromiseArray(obj) {
3536
- var keys = es5.keys(obj);
3537
- var len = keys.length;
3538
- var values = new Array(len * 2);
3539
- for (var i = 0; i < len; ++i) {
3540
- var key = keys[i];
3541
- values[i] = obj[key];
3542
- values[i + len] = key;
3543
- }
3544
- this.constructor$(values);
3545
- }
3546
- util.inherits(PropertiesPromiseArray, PromiseArray);
3547
-
3548
- PropertiesPromiseArray.prototype._init = function () {
3549
- this._init$(undefined, -3) ;
3550
- };
3551
-
3552
- PropertiesPromiseArray.prototype._promiseFulfilled = function (value, index) {
3553
- this._values[index] = value;
3554
- var totalResolved = ++this._totalResolved;
3555
- if (totalResolved >= this._length) {
3556
- var val = {};
3557
- var keyOffset = this.length();
3558
- for (var i = 0, len = this.length(); i < len; ++i) {
3559
- val[this._values[i + keyOffset]] = this._values[i];
3560
- }
3561
- this._resolve(val);
3562
- }
3563
- };
3564
-
3565
- PropertiesPromiseArray.prototype._promiseProgressed = function (value, index) {
3566
- this._promise._progress({
3567
- key: this._values[index + this.length()],
3568
- value: value
3569
- });
3570
- };
3571
-
3572
- PropertiesPromiseArray.prototype.shouldCopyValues = function () {
3573
- return false;
3574
- };
3575
-
3576
- PropertiesPromiseArray.prototype.getActualLength = function (len) {
3577
- return len >> 1;
3578
- };
3579
-
3580
- function props(promises) {
3581
- var ret;
3582
- var castValue = tryConvertToPromise(promises);
3583
-
3584
- if (!isObject(castValue)) {
3585
- return apiRejection("cannot await properties of a non-object\u000a\u000a See http://goo.gl/OsFKC8\u000a");
3586
- } else if (castValue instanceof Promise) {
3587
- ret = castValue._then(
3588
- Promise.props, undefined, undefined, undefined, undefined);
3589
- } else {
3590
- ret = new PropertiesPromiseArray(castValue).promise();
3591
- }
3592
-
3593
- if (castValue instanceof Promise) {
3594
- ret._propagateFrom(castValue, 4);
3595
- }
3596
- return ret;
3597
- }
3598
-
3599
- Promise.prototype.props = function () {
3600
- return props(this);
3601
- };
3602
-
3603
- Promise.props = function (promises) {
3604
- return props(promises);
3605
- };
3606
- };
3607
-
3608
- },{"./es5.js":14,"./util.js":38}],28:[function(_dereq_,module,exports){
3609
- "use strict";
3610
- function arrayMove(src, srcIndex, dst, dstIndex, len) {
3611
- for (var j = 0; j < len; ++j) {
3612
- dst[j + dstIndex] = src[j + srcIndex];
3613
- src[j + srcIndex] = void 0;
3614
- }
3615
- }
3616
-
3617
- function Queue(capacity) {
3618
- this._capacity = capacity;
3619
- this._length = 0;
3620
- this._front = 0;
3621
- }
3622
-
3623
- Queue.prototype._willBeOverCapacity = function (size) {
3624
- return this._capacity < size;
3625
- };
3626
-
3627
- Queue.prototype._pushOne = function (arg) {
3628
- var length = this.length();
3629
- this._checkCapacity(length + 1);
3630
- var i = (this._front + length) & (this._capacity - 1);
3631
- this[i] = arg;
3632
- this._length = length + 1;
3633
- };
3634
-
3635
- Queue.prototype._unshiftOne = function(value) {
3636
- var capacity = this._capacity;
3637
- this._checkCapacity(this.length() + 1);
3638
- var front = this._front;
3639
- var i = (((( front - 1 ) &
3640
- ( capacity - 1) ) ^ capacity ) - capacity );
3641
- this[i] = value;
3642
- this._front = i;
3643
- this._length = this.length() + 1;
3644
- };
3645
-
3646
- Queue.prototype.unshift = function(fn, receiver, arg) {
3647
- this._unshiftOne(arg);
3648
- this._unshiftOne(receiver);
3649
- this._unshiftOne(fn);
3650
- };
3651
-
3652
- Queue.prototype.push = function (fn, receiver, arg) {
3653
- var length = this.length() + 3;
3654
- if (this._willBeOverCapacity(length)) {
3655
- this._pushOne(fn);
3656
- this._pushOne(receiver);
3657
- this._pushOne(arg);
3658
- return;
3659
- }
3660
- var j = this._front + length - 3;
3661
- this._checkCapacity(length);
3662
- var wrapMask = this._capacity - 1;
3663
- this[(j + 0) & wrapMask] = fn;
3664
- this[(j + 1) & wrapMask] = receiver;
3665
- this[(j + 2) & wrapMask] = arg;
3666
- this._length = length;
3667
- };
3668
-
3669
- Queue.prototype.shift = function () {
3670
- var front = this._front,
3671
- ret = this[front];
3672
-
3673
- this[front] = undefined;
3674
- this._front = (front + 1) & (this._capacity - 1);
3675
- this._length--;
3676
- return ret;
3677
- };
3678
-
3679
- Queue.prototype.length = function () {
3680
- return this._length;
3681
- };
3682
-
3683
- Queue.prototype._checkCapacity = function (size) {
3684
- if (this._capacity < size) {
3685
- this._resizeTo(this._capacity << 1);
3686
- }
3687
- };
3688
-
3689
- Queue.prototype._resizeTo = function (capacity) {
3690
- var oldCapacity = this._capacity;
3691
- this._capacity = capacity;
3692
- var front = this._front;
3693
- var length = this._length;
3694
- var moveItemsCount = (front + length) & (oldCapacity - 1);
3695
- arrayMove(this, 0, this, oldCapacity, moveItemsCount);
3696
- };
3697
-
3698
- module.exports = Queue;
3699
-
3700
- },{}],29:[function(_dereq_,module,exports){
3701
- "use strict";
3702
- module.exports = function(
3703
- Promise, INTERNAL, tryConvertToPromise, apiRejection) {
3704
- var isArray = _dereq_("./util.js").isArray;
3705
-
3706
- var raceLater = function (promise) {
3707
- return promise.then(function(array) {
3708
- return race(array, promise);
3709
- });
3710
- };
3711
-
3712
- function race(promises, parent) {
3713
- var maybePromise = tryConvertToPromise(promises);
3714
-
3715
- if (maybePromise instanceof Promise) {
3716
- return raceLater(maybePromise);
3717
- } else if (!isArray(promises)) {
3718
- return apiRejection("expecting an array, a promise or a thenable\u000a\u000a See http://goo.gl/s8MMhc\u000a");
3719
- }
3720
-
3721
- var ret = new Promise(INTERNAL);
3722
- if (parent !== undefined) {
3723
- ret._propagateFrom(parent, 4 | 1);
3724
- }
3725
- var fulfill = ret._fulfill;
3726
- var reject = ret._reject;
3727
- for (var i = 0, len = promises.length; i < len; ++i) {
3728
- var val = promises[i];
3729
-
3730
- if (val === undefined && !(i in promises)) {
3731
- continue;
3732
- }
3733
-
3734
- Promise.cast(val)._then(fulfill, reject, undefined, ret, null);
3735
- }
3736
- return ret;
3737
- }
3738
-
3739
- Promise.race = function (promises) {
3740
- return race(promises, undefined);
3741
- };
3742
-
3743
- Promise.prototype.race = function () {
3744
- return race(this, undefined);
3745
- };
3746
-
3747
- };
3748
-
3749
- },{"./util.js":38}],30:[function(_dereq_,module,exports){
3750
- "use strict";
3751
- module.exports = function(Promise,
3752
- PromiseArray,
3753
- apiRejection,
3754
- tryConvertToPromise,
3755
- INTERNAL) {
3756
- var getDomain = Promise._getDomain;
3757
- var async = _dereq_("./async.js");
3758
- var util = _dereq_("./util.js");
3759
- var tryCatch = util.tryCatch;
3760
- var errorObj = util.errorObj;
3761
- function ReductionPromiseArray(promises, fn, accum, _each) {
3762
- this.constructor$(promises);
3763
- this._promise._captureStackTrace();
3764
- this._preservedValues = _each === INTERNAL ? [] : null;
3765
- this._zerothIsAccum = (accum === undefined);
3766
- this._gotAccum = false;
3767
- this._reducingIndex = (this._zerothIsAccum ? 1 : 0);
3768
- this._valuesPhase = undefined;
3769
- var maybePromise = tryConvertToPromise(accum, this._promise);
3770
- var rejected = false;
3771
- var isPromise = maybePromise instanceof Promise;
3772
- if (isPromise) {
3773
- maybePromise = maybePromise._target();
3774
- if (maybePromise._isPending()) {
3775
- maybePromise._proxyPromiseArray(this, -1);
3776
- } else if (maybePromise._isFulfilled()) {
3777
- accum = maybePromise._value();
3778
- this._gotAccum = true;
3779
- } else {
3780
- this._reject(maybePromise._reason());
3781
- rejected = true;
3782
- }
3783
- }
3784
- if (!(isPromise || this._zerothIsAccum)) this._gotAccum = true;
3785
- var domain = getDomain();
3786
- this._callback = domain === null ? fn : domain.bind(fn);
3787
- this._accum = accum;
3788
- if (!rejected) async.invoke(init, this, undefined);
3789
- }
3790
- function init() {
3791
- this._init$(undefined, -5);
3792
- }
3793
- util.inherits(ReductionPromiseArray, PromiseArray);
3794
-
3795
- ReductionPromiseArray.prototype._init = function () {};
3796
-
3797
- ReductionPromiseArray.prototype._resolveEmptyArray = function () {
3798
- if (this._gotAccum || this._zerothIsAccum) {
3799
- this._resolve(this._preservedValues !== null
3800
- ? [] : this._accum);
3801
- }
3802
- };
3803
-
3804
- ReductionPromiseArray.prototype._promiseFulfilled = function (value, index) {
3805
- var values = this._values;
3806
- values[index] = value;
3807
- var length = this.length();
3808
- var preservedValues = this._preservedValues;
3809
- var isEach = preservedValues !== null;
3810
- var gotAccum = this._gotAccum;
3811
- var valuesPhase = this._valuesPhase;
3812
- var valuesPhaseIndex;
3813
- if (!valuesPhase) {
3814
- valuesPhase = this._valuesPhase = new Array(length);
3815
- for (valuesPhaseIndex=0; valuesPhaseIndex<length; ++valuesPhaseIndex) {
3816
- valuesPhase[valuesPhaseIndex] = 0;
3817
- }
3818
- }
3819
- valuesPhaseIndex = valuesPhase[index];
3820
-
3821
- if (index === 0 && this._zerothIsAccum) {
3822
- this._accum = value;
3823
- this._gotAccum = gotAccum = true;
3824
- valuesPhase[index] = ((valuesPhaseIndex === 0)
3825
- ? 1 : 2);
3826
- } else if (index === -1) {
3827
- this._accum = value;
3828
- this._gotAccum = gotAccum = true;
3829
- } else {
3830
- if (valuesPhaseIndex === 0) {
3831
- valuesPhase[index] = 1;
3832
- } else {
3833
- valuesPhase[index] = 2;
3834
- this._accum = value;
3835
- }
3836
- }
3837
- if (!gotAccum) return;
3838
-
3839
- var callback = this._callback;
3840
- var receiver = this._promise._boundValue();
3841
- var ret;
3842
-
3843
- for (var i = this._reducingIndex; i < length; ++i) {
3844
- valuesPhaseIndex = valuesPhase[i];
3845
- if (valuesPhaseIndex === 2) {
3846
- this._reducingIndex = i + 1;
3847
- continue;
3848
- }
3849
- if (valuesPhaseIndex !== 1) return;
3850
- value = values[i];
3851
- this._promise._pushContext();
3852
- if (isEach) {
3853
- preservedValues.push(value);
3854
- ret = tryCatch(callback).call(receiver, value, i, length);
3855
- }
3856
- else {
3857
- ret = tryCatch(callback)
3858
- .call(receiver, this._accum, value, i, length);
3859
- }
3860
- this._promise._popContext();
3861
-
3862
- if (ret === errorObj) return this._reject(ret.e);
3863
-
3864
- var maybePromise = tryConvertToPromise(ret, this._promise);
3865
- if (maybePromise instanceof Promise) {
3866
- maybePromise = maybePromise._target();
3867
- if (maybePromise._isPending()) {
3868
- valuesPhase[i] = 4;
3869
- return maybePromise._proxyPromiseArray(this, i);
3870
- } else if (maybePromise._isFulfilled()) {
3871
- ret = maybePromise._value();
3872
- } else {
3873
- return this._reject(maybePromise._reason());
3874
- }
3875
- }
3876
-
3877
- this._reducingIndex = i + 1;
3878
- this._accum = ret;
3879
- }
3880
-
3881
- this._resolve(isEach ? preservedValues : this._accum);
3882
- };
3883
-
3884
- function reduce(promises, fn, initialValue, _each) {
3885
- if (typeof fn !== "function") return apiRejection("fn must be a function\u000a\u000a See http://goo.gl/916lJJ\u000a");
3886
- var array = new ReductionPromiseArray(promises, fn, initialValue, _each);
3887
- return array.promise();
3888
- }
3889
-
3890
- Promise.prototype.reduce = function (fn, initialValue) {
3891
- return reduce(this, fn, initialValue, null);
3892
- };
3893
-
3894
- Promise.reduce = function (promises, fn, initialValue, _each) {
3895
- return reduce(promises, fn, initialValue, _each);
3896
- };
3897
- };
3898
-
3899
- },{"./async.js":2,"./util.js":38}],31:[function(_dereq_,module,exports){
3900
- "use strict";
3901
- var schedule;
3902
- var util = _dereq_("./util");
3903
- var noAsyncScheduler = function() {
3904
- throw new Error("No async scheduler available\u000a\u000a See http://goo.gl/m3OTXk\u000a");
3905
- };
3906
- if (util.isNode && typeof MutationObserver === "undefined") {
3907
- var GlobalSetImmediate = global.setImmediate;
3908
- var ProcessNextTick = process.nextTick;
3909
- schedule = util.isRecentNode
3910
- ? function(fn) { GlobalSetImmediate.call(global, fn); }
3911
- : function(fn) { ProcessNextTick.call(process, fn); };
3912
- } else if ((typeof MutationObserver !== "undefined") &&
3913
- !(typeof window !== "undefined" &&
3914
- window.navigator &&
3915
- window.navigator.standalone)) {
3916
- schedule = function(fn) {
3917
- var div = document.createElement("div");
3918
- var observer = new MutationObserver(fn);
3919
- observer.observe(div, {attributes: true});
3920
- return function() { div.classList.toggle("foo"); };
3921
- };
3922
- schedule.isStatic = true;
3923
- } else if (typeof setImmediate !== "undefined") {
3924
- schedule = function (fn) {
3925
- setImmediate(fn);
3926
- };
3927
- } else if (typeof setTimeout !== "undefined") {
3928
- schedule = function (fn) {
3929
- setTimeout(fn, 0);
3930
- };
3931
- } else {
3932
- schedule = noAsyncScheduler;
3933
- }
3934
- module.exports = schedule;
3935
-
3936
- },{"./util":38}],32:[function(_dereq_,module,exports){
3937
- "use strict";
3938
- module.exports =
3939
- function(Promise, PromiseArray) {
3940
- var PromiseInspection = Promise.PromiseInspection;
3941
- var util = _dereq_("./util.js");
3942
-
3943
- function SettledPromiseArray(values) {
3944
- this.constructor$(values);
3945
- }
3946
- util.inherits(SettledPromiseArray, PromiseArray);
3947
-
3948
- SettledPromiseArray.prototype._promiseResolved = function (index, inspection) {
3949
- this._values[index] = inspection;
3950
- var totalResolved = ++this._totalResolved;
3951
- if (totalResolved >= this._length) {
3952
- this._resolve(this._values);
3953
- }
3954
- };
3955
-
3956
- SettledPromiseArray.prototype._promiseFulfilled = function (value, index) {
3957
- var ret = new PromiseInspection();
3958
- ret._bitField = 268435456;
3959
- ret._settledValue = value;
3960
- this._promiseResolved(index, ret);
3961
- };
3962
- SettledPromiseArray.prototype._promiseRejected = function (reason, index) {
3963
- var ret = new PromiseInspection();
3964
- ret._bitField = 134217728;
3965
- ret._settledValue = reason;
3966
- this._promiseResolved(index, ret);
3967
- };
3968
-
3969
- Promise.settle = function (promises) {
3970
- return new SettledPromiseArray(promises).promise();
3971
- };
3972
-
3973
- Promise.prototype.settle = function () {
3974
- return new SettledPromiseArray(this).promise();
3975
- };
3976
- };
3977
-
3978
- },{"./util.js":38}],33:[function(_dereq_,module,exports){
3979
- "use strict";
3980
- module.exports =
3981
- function(Promise, PromiseArray, apiRejection) {
3982
- var util = _dereq_("./util.js");
3983
- var RangeError = _dereq_("./errors.js").RangeError;
3984
- var AggregateError = _dereq_("./errors.js").AggregateError;
3985
- var isArray = util.isArray;
3986
-
3987
-
3988
- function SomePromiseArray(values) {
3989
- this.constructor$(values);
3990
- this._howMany = 0;
3991
- this._unwrap = false;
3992
- this._initialized = false;
3993
- }
3994
- util.inherits(SomePromiseArray, PromiseArray);
3995
-
3996
- SomePromiseArray.prototype._init = function () {
3997
- if (!this._initialized) {
3998
- return;
3999
- }
4000
- if (this._howMany === 0) {
4001
- this._resolve([]);
4002
- return;
4003
- }
4004
- this._init$(undefined, -5);
4005
- var isArrayResolved = isArray(this._values);
4006
- if (!this._isResolved() &&
4007
- isArrayResolved &&
4008
- this._howMany > this._canPossiblyFulfill()) {
4009
- this._reject(this._getRangeError(this.length()));
4010
- }
4011
- };
4012
-
4013
- SomePromiseArray.prototype.init = function () {
4014
- this._initialized = true;
4015
- this._init();
4016
- };
4017
-
4018
- SomePromiseArray.prototype.setUnwrap = function () {
4019
- this._unwrap = true;
4020
- };
4021
-
4022
- SomePromiseArray.prototype.howMany = function () {
4023
- return this._howMany;
4024
- };
4025
-
4026
- SomePromiseArray.prototype.setHowMany = function (count) {
4027
- this._howMany = count;
4028
- };
4029
-
4030
- SomePromiseArray.prototype._promiseFulfilled = function (value) {
4031
- this._addFulfilled(value);
4032
- if (this._fulfilled() === this.howMany()) {
4033
- this._values.length = this.howMany();
4034
- if (this.howMany() === 1 && this._unwrap) {
4035
- this._resolve(this._values[0]);
4036
- } else {
4037
- this._resolve(this._values);
4038
- }
4039
- }
4040
-
4041
- };
4042
- SomePromiseArray.prototype._promiseRejected = function (reason) {
4043
- this._addRejected(reason);
4044
- if (this.howMany() > this._canPossiblyFulfill()) {
4045
- var e = new AggregateError();
4046
- for (var i = this.length(); i < this._values.length; ++i) {
4047
- e.push(this._values[i]);
4048
- }
4049
- this._reject(e);
4050
- }
4051
- };
4052
-
4053
- SomePromiseArray.prototype._fulfilled = function () {
4054
- return this._totalResolved;
4055
- };
4056
-
4057
- SomePromiseArray.prototype._rejected = function () {
4058
- return this._values.length - this.length();
4059
- };
4060
-
4061
- SomePromiseArray.prototype._addRejected = function (reason) {
4062
- this._values.push(reason);
4063
- };
4064
-
4065
- SomePromiseArray.prototype._addFulfilled = function (value) {
4066
- this._values[this._totalResolved++] = value;
4067
- };
4068
-
4069
- SomePromiseArray.prototype._canPossiblyFulfill = function () {
4070
- return this.length() - this._rejected();
4071
- };
4072
-
4073
- SomePromiseArray.prototype._getRangeError = function (count) {
4074
- var message = "Input array must contain at least " +
4075
- this._howMany + " items but contains only " + count + " items";
4076
- return new RangeError(message);
4077
- };
4078
-
4079
- SomePromiseArray.prototype._resolveEmptyArray = function () {
4080
- this._reject(this._getRangeError(0));
4081
- };
4082
-
4083
- function some(promises, howMany) {
4084
- if ((howMany | 0) !== howMany || howMany < 0) {
4085
- return apiRejection("expecting a positive integer\u000a\u000a See http://goo.gl/1wAmHx\u000a");
4086
- }
4087
- var ret = new SomePromiseArray(promises);
4088
- var promise = ret.promise();
4089
- ret.setHowMany(howMany);
4090
- ret.init();
4091
- return promise;
4092
- }
4093
-
4094
- Promise.some = function (promises, howMany) {
4095
- return some(promises, howMany);
4096
- };
4097
-
4098
- Promise.prototype.some = function (howMany) {
4099
- return some(this, howMany);
4100
- };
4101
-
4102
- Promise._SomePromiseArray = SomePromiseArray;
4103
- };
4104
-
4105
- },{"./errors.js":13,"./util.js":38}],34:[function(_dereq_,module,exports){
4106
- "use strict";
4107
- module.exports = function(Promise) {
4108
- function PromiseInspection(promise) {
4109
- if (promise !== undefined) {
4110
- promise = promise._target();
4111
- this._bitField = promise._bitField;
4112
- this._settledValue = promise._settledValue;
4113
- }
4114
- else {
4115
- this._bitField = 0;
4116
- this._settledValue = undefined;
4117
- }
4118
- }
4119
-
4120
- PromiseInspection.prototype.value = function () {
4121
- if (!this.isFulfilled()) {
4122
- throw new TypeError("cannot get fulfillment value of a non-fulfilled promise\u000a\u000a See http://goo.gl/hc1DLj\u000a");
4123
- }
4124
- return this._settledValue;
4125
- };
4126
-
4127
- PromiseInspection.prototype.error =
4128
- PromiseInspection.prototype.reason = function () {
4129
- if (!this.isRejected()) {
4130
- throw new TypeError("cannot get rejection reason of a non-rejected promise\u000a\u000a See http://goo.gl/hPuiwB\u000a");
4131
- }
4132
- return this._settledValue;
4133
- };
4134
-
4135
- PromiseInspection.prototype.isFulfilled =
4136
- Promise.prototype._isFulfilled = function () {
4137
- return (this._bitField & 268435456) > 0;
4138
- };
4139
-
4140
- PromiseInspection.prototype.isRejected =
4141
- Promise.prototype._isRejected = function () {
4142
- return (this._bitField & 134217728) > 0;
4143
- };
4144
-
4145
- PromiseInspection.prototype.isPending =
4146
- Promise.prototype._isPending = function () {
4147
- return (this._bitField & 402653184) === 0;
4148
- };
4149
-
4150
- PromiseInspection.prototype.isResolved =
4151
- Promise.prototype._isResolved = function () {
4152
- return (this._bitField & 402653184) > 0;
4153
- };
4154
-
4155
- Promise.prototype.isPending = function() {
4156
- return this._target()._isPending();
4157
- };
4158
-
4159
- Promise.prototype.isRejected = function() {
4160
- return this._target()._isRejected();
4161
- };
4162
-
4163
- Promise.prototype.isFulfilled = function() {
4164
- return this._target()._isFulfilled();
4165
- };
4166
-
4167
- Promise.prototype.isResolved = function() {
4168
- return this._target()._isResolved();
4169
- };
4170
-
4171
- Promise.prototype._value = function() {
4172
- return this._settledValue;
4173
- };
4174
-
4175
- Promise.prototype._reason = function() {
4176
- this._unsetRejectionIsUnhandled();
4177
- return this._settledValue;
4178
- };
4179
-
4180
- Promise.prototype.value = function() {
4181
- var target = this._target();
4182
- if (!target.isFulfilled()) {
4183
- throw new TypeError("cannot get fulfillment value of a non-fulfilled promise\u000a\u000a See http://goo.gl/hc1DLj\u000a");
4184
- }
4185
- return target._settledValue;
4186
- };
4187
-
4188
- Promise.prototype.reason = function() {
4189
- var target = this._target();
4190
- if (!target.isRejected()) {
4191
- throw new TypeError("cannot get rejection reason of a non-rejected promise\u000a\u000a See http://goo.gl/hPuiwB\u000a");
4192
- }
4193
- target._unsetRejectionIsUnhandled();
4194
- return target._settledValue;
4195
- };
4196
-
4197
-
4198
- Promise.PromiseInspection = PromiseInspection;
4199
- };
4200
-
4201
- },{}],35:[function(_dereq_,module,exports){
4202
- "use strict";
4203
- module.exports = function(Promise, INTERNAL) {
4204
- var util = _dereq_("./util.js");
4205
- var errorObj = util.errorObj;
4206
- var isObject = util.isObject;
4207
-
4208
- function tryConvertToPromise(obj, context) {
4209
- if (isObject(obj)) {
4210
- if (obj instanceof Promise) {
4211
- return obj;
4212
- }
4213
- else if (isAnyBluebirdPromise(obj)) {
4214
- var ret = new Promise(INTERNAL);
4215
- obj._then(
4216
- ret._fulfillUnchecked,
4217
- ret._rejectUncheckedCheckError,
4218
- ret._progressUnchecked,
4219
- ret,
4220
- null
4221
- );
4222
- return ret;
4223
- }
4224
- var then = util.tryCatch(getThen)(obj);
4225
- if (then === errorObj) {
4226
- if (context) context._pushContext();
4227
- var ret = Promise.reject(then.e);
4228
- if (context) context._popContext();
4229
- return ret;
4230
- } else if (typeof then === "function") {
4231
- return doThenable(obj, then, context);
4232
- }
4233
- }
4234
- return obj;
4235
- }
4236
-
4237
- function getThen(obj) {
4238
- return obj.then;
4239
- }
4240
-
4241
- var hasProp = {}.hasOwnProperty;
4242
- function isAnyBluebirdPromise(obj) {
4243
- return hasProp.call(obj, "_promise0");
4244
- }
4245
-
4246
- function doThenable(x, then, context) {
4247
- var promise = new Promise(INTERNAL);
4248
- var ret = promise;
4249
- if (context) context._pushContext();
4250
- promise._captureStackTrace();
4251
- if (context) context._popContext();
4252
- var synchronous = true;
4253
- var result = util.tryCatch(then).call(x,
4254
- resolveFromThenable,
4255
- rejectFromThenable,
4256
- progressFromThenable);
4257
- synchronous = false;
4258
- if (promise && result === errorObj) {
4259
- promise._rejectCallback(result.e, true, true);
4260
- promise = null;
4261
- }
4262
-
4263
- function resolveFromThenable(value) {
4264
- if (!promise) return;
4265
- promise._resolveCallback(value);
4266
- promise = null;
4267
- }
4268
-
4269
- function rejectFromThenable(reason) {
4270
- if (!promise) return;
4271
- promise._rejectCallback(reason, synchronous, true);
4272
- promise = null;
4273
- }
4274
-
4275
- function progressFromThenable(value) {
4276
- if (!promise) return;
4277
- if (typeof promise._progress === "function") {
4278
- promise._progress(value);
4279
- }
4280
- }
4281
- return ret;
4282
- }
4283
-
4284
- return tryConvertToPromise;
4285
- };
4286
-
4287
- },{"./util.js":38}],36:[function(_dereq_,module,exports){
4288
- "use strict";
4289
- module.exports = function(Promise, INTERNAL) {
4290
- var util = _dereq_("./util.js");
4291
- var TimeoutError = Promise.TimeoutError;
4292
-
4293
- var afterTimeout = function (promise, message) {
4294
- if (!promise.isPending()) return;
4295
-
4296
- var err;
4297
- if(!util.isPrimitive(message) && (message instanceof Error)) {
4298
- err = message;
4299
- } else {
4300
- if (typeof message !== "string") {
4301
- message = "operation timed out";
4302
- }
4303
- err = new TimeoutError(message);
4304
- }
4305
- util.markAsOriginatingFromRejection(err);
4306
- promise._attachExtraTrace(err);
4307
- promise._cancel(err);
4308
- };
4309
-
4310
- var afterValue = function(value) { return delay(+this).thenReturn(value); };
4311
- var delay = Promise.delay = function (value, ms) {
4312
- if (ms === undefined) {
4313
- ms = value;
4314
- value = undefined;
4315
- var ret = new Promise(INTERNAL);
4316
- setTimeout(function() { ret._fulfill(); }, ms);
4317
- return ret;
4318
- }
4319
- ms = +ms;
4320
- return Promise.resolve(value)._then(afterValue, null, null, ms, undefined);
4321
- };
4322
-
4323
- Promise.prototype.delay = function (ms) {
4324
- return delay(this, ms);
4325
- };
4326
-
4327
- function successClear(value) {
4328
- var handle = this;
4329
- if (handle instanceof Number) handle = +handle;
4330
- clearTimeout(handle);
4331
- return value;
4332
- }
4333
-
4334
- function failureClear(reason) {
4335
- var handle = this;
4336
- if (handle instanceof Number) handle = +handle;
4337
- clearTimeout(handle);
4338
- throw reason;
4339
- }
4340
-
4341
- Promise.prototype.timeout = function (ms, message) {
4342
- ms = +ms;
4343
- var ret = this.then().cancellable();
4344
- ret._cancellationParent = this;
4345
- var handle = setTimeout(function timeoutTimeout() {
4346
- afterTimeout(ret, message);
4347
- }, ms);
4348
- return ret._then(successClear, failureClear, undefined, handle, undefined);
4349
- };
4350
-
4351
- };
4352
-
4353
- },{"./util.js":38}],37:[function(_dereq_,module,exports){
4354
- "use strict";
4355
- module.exports = function (Promise, apiRejection, tryConvertToPromise,
4356
- createContext) {
4357
- var TypeError = _dereq_("./errors.js").TypeError;
4358
- var inherits = _dereq_("./util.js").inherits;
4359
- var PromiseInspection = Promise.PromiseInspection;
4360
-
4361
- function inspectionMapper(inspections) {
4362
- var len = inspections.length;
4363
- for (var i = 0; i < len; ++i) {
4364
- var inspection = inspections[i];
4365
- if (inspection.isRejected()) {
4366
- return Promise.reject(inspection.error());
4367
- }
4368
- inspections[i] = inspection._settledValue;
4369
- }
4370
- return inspections;
4371
- }
4372
-
4373
- function thrower(e) {
4374
- setTimeout(function(){throw e;}, 0);
4375
- }
4376
-
4377
- function castPreservingDisposable(thenable) {
4378
- var maybePromise = tryConvertToPromise(thenable);
4379
- if (maybePromise !== thenable &&
4380
- typeof thenable._isDisposable === "function" &&
4381
- typeof thenable._getDisposer === "function" &&
4382
- thenable._isDisposable()) {
4383
- maybePromise._setDisposable(thenable._getDisposer());
4384
- }
4385
- return maybePromise;
4386
- }
4387
- function dispose(resources, inspection) {
4388
- var i = 0;
4389
- var len = resources.length;
4390
- var ret = Promise.defer();
4391
- function iterator() {
4392
- if (i >= len) return ret.resolve();
4393
- var maybePromise = castPreservingDisposable(resources[i++]);
4394
- if (maybePromise instanceof Promise &&
4395
- maybePromise._isDisposable()) {
4396
- try {
4397
- maybePromise = tryConvertToPromise(
4398
- maybePromise._getDisposer().tryDispose(inspection),
4399
- resources.promise);
4400
- } catch (e) {
4401
- return thrower(e);
4402
- }
4403
- if (maybePromise instanceof Promise) {
4404
- return maybePromise._then(iterator, thrower,
4405
- null, null, null);
4406
- }
4407
- }
4408
- iterator();
4409
- }
4410
- iterator();
4411
- return ret.promise;
4412
- }
4413
-
4414
- function disposerSuccess(value) {
4415
- var inspection = new PromiseInspection();
4416
- inspection._settledValue = value;
4417
- inspection._bitField = 268435456;
4418
- return dispose(this, inspection).thenReturn(value);
4419
- }
4420
-
4421
- function disposerFail(reason) {
4422
- var inspection = new PromiseInspection();
4423
- inspection._settledValue = reason;
4424
- inspection._bitField = 134217728;
4425
- return dispose(this, inspection).thenThrow(reason);
4426
- }
4427
-
4428
- function Disposer(data, promise, context) {
4429
- this._data = data;
4430
- this._promise = promise;
4431
- this._context = context;
4432
- }
4433
-
4434
- Disposer.prototype.data = function () {
4435
- return this._data;
4436
- };
4437
-
4438
- Disposer.prototype.promise = function () {
4439
- return this._promise;
4440
- };
4441
-
4442
- Disposer.prototype.resource = function () {
4443
- if (this.promise().isFulfilled()) {
4444
- return this.promise().value();
4445
- }
4446
- return null;
4447
- };
4448
-
4449
- Disposer.prototype.tryDispose = function(inspection) {
4450
- var resource = this.resource();
4451
- var context = this._context;
4452
- if (context !== undefined) context._pushContext();
4453
- var ret = resource !== null
4454
- ? this.doDispose(resource, inspection) : null;
4455
- if (context !== undefined) context._popContext();
4456
- this._promise._unsetDisposable();
4457
- this._data = null;
4458
- return ret;
4459
- };
4460
-
4461
- Disposer.isDisposer = function (d) {
4462
- return (d != null &&
4463
- typeof d.resource === "function" &&
4464
- typeof d.tryDispose === "function");
4465
- };
4466
-
4467
- function FunctionDisposer(fn, promise, context) {
4468
- this.constructor$(fn, promise, context);
4469
- }
4470
- inherits(FunctionDisposer, Disposer);
4471
-
4472
- FunctionDisposer.prototype.doDispose = function (resource, inspection) {
4473
- var fn = this.data();
4474
- return fn.call(resource, resource, inspection);
4475
- };
4476
-
4477
- function maybeUnwrapDisposer(value) {
4478
- if (Disposer.isDisposer(value)) {
4479
- this.resources[this.index]._setDisposable(value);
4480
- return value.promise();
4481
- }
4482
- return value;
4483
- }
4484
-
4485
- Promise.using = function () {
4486
- var len = arguments.length;
4487
- if (len < 2) return apiRejection(
4488
- "you must pass at least 2 arguments to Promise.using");
4489
- var fn = arguments[len - 1];
4490
- if (typeof fn !== "function") return apiRejection("fn must be a function\u000a\u000a See http://goo.gl/916lJJ\u000a");
4491
-
4492
- var input;
4493
- var spreadArgs = true;
4494
- if (len === 2 && Array.isArray(arguments[0])) {
4495
- input = arguments[0];
4496
- len = input.length;
4497
- spreadArgs = false;
4498
- } else {
4499
- input = arguments;
4500
- len--;
4501
- }
4502
- var resources = new Array(len);
4503
- for (var i = 0; i < len; ++i) {
4504
- var resource = input[i];
4505
- if (Disposer.isDisposer(resource)) {
4506
- var disposer = resource;
4507
- resource = resource.promise();
4508
- resource._setDisposable(disposer);
4509
- } else {
4510
- var maybePromise = tryConvertToPromise(resource);
4511
- if (maybePromise instanceof Promise) {
4512
- resource =
4513
- maybePromise._then(maybeUnwrapDisposer, null, null, {
4514
- resources: resources,
4515
- index: i
4516
- }, undefined);
4517
- }
4518
- }
4519
- resources[i] = resource;
4520
- }
4521
-
4522
- var promise = Promise.settle(resources)
4523
- .then(inspectionMapper)
4524
- .then(function(vals) {
4525
- promise._pushContext();
4526
- var ret;
4527
- try {
4528
- ret = spreadArgs
4529
- ? fn.apply(undefined, vals) : fn.call(undefined, vals);
4530
- } finally {
4531
- promise._popContext();
4532
- }
4533
- return ret;
4534
- })
4535
- ._then(
4536
- disposerSuccess, disposerFail, undefined, resources, undefined);
4537
- resources.promise = promise;
4538
- return promise;
4539
- };
4540
-
4541
- Promise.prototype._setDisposable = function (disposer) {
4542
- this._bitField = this._bitField | 262144;
4543
- this._disposer = disposer;
4544
- };
4545
-
4546
- Promise.prototype._isDisposable = function () {
4547
- return (this._bitField & 262144) > 0;
4548
- };
4549
-
4550
- Promise.prototype._getDisposer = function () {
4551
- return this._disposer;
4552
- };
4553
-
4554
- Promise.prototype._unsetDisposable = function () {
4555
- this._bitField = this._bitField & (~262144);
4556
- this._disposer = undefined;
4557
- };
4558
-
4559
- Promise.prototype.disposer = function (fn) {
4560
- if (typeof fn === "function") {
4561
- return new FunctionDisposer(fn, this, createContext());
4562
- }
4563
- throw new TypeError();
4564
- };
4565
-
4566
- };
4567
-
4568
- },{"./errors.js":13,"./util.js":38}],38:[function(_dereq_,module,exports){
4569
- "use strict";
4570
- var es5 = _dereq_("./es5.js");
4571
- var canEvaluate = typeof navigator == "undefined";
4572
- var haveGetters = (function(){
4573
- try {
4574
- var o = {};
4575
- es5.defineProperty(o, "f", {
4576
- get: function () {
4577
- return 3;
4578
- }
4579
- });
4580
- return o.f === 3;
4581
- }
4582
- catch (e) {
4583
- return false;
4584
- }
4585
-
4586
- })();
4587
-
4588
- var errorObj = {e: {}};
4589
- var tryCatchTarget;
4590
- function tryCatcher() {
4591
- try {
4592
- var target = tryCatchTarget;
4593
- tryCatchTarget = null;
4594
- return target.apply(this, arguments);
4595
- } catch (e) {
4596
- errorObj.e = e;
4597
- return errorObj;
4598
- }
4599
- }
4600
- function tryCatch(fn) {
4601
- tryCatchTarget = fn;
4602
- return tryCatcher;
4603
- }
4604
-
4605
- var inherits = function(Child, Parent) {
4606
- var hasProp = {}.hasOwnProperty;
4607
-
4608
- function T() {
4609
- this.constructor = Child;
4610
- this.constructor$ = Parent;
4611
- for (var propertyName in Parent.prototype) {
4612
- if (hasProp.call(Parent.prototype, propertyName) &&
4613
- propertyName.charAt(propertyName.length-1) !== "$"
4614
- ) {
4615
- this[propertyName + "$"] = Parent.prototype[propertyName];
4616
- }
4617
- }
4618
- }
4619
- T.prototype = Parent.prototype;
4620
- Child.prototype = new T();
4621
- return Child.prototype;
4622
- };
4623
-
4624
-
4625
- function isPrimitive(val) {
4626
- return val == null || val === true || val === false ||
4627
- typeof val === "string" || typeof val === "number";
4628
-
4629
- }
4630
-
4631
- function isObject(value) {
4632
- return !isPrimitive(value);
4633
- }
4634
-
4635
- function maybeWrapAsError(maybeError) {
4636
- if (!isPrimitive(maybeError)) return maybeError;
4637
-
4638
- return new Error(safeToString(maybeError));
4639
- }
4640
-
4641
- function withAppended(target, appendee) {
4642
- var len = target.length;
4643
- var ret = new Array(len + 1);
4644
- var i;
4645
- for (i = 0; i < len; ++i) {
4646
- ret[i] = target[i];
4647
- }
4648
- ret[i] = appendee;
4649
- return ret;
4650
- }
4651
-
4652
- function getDataPropertyOrDefault(obj, key, defaultValue) {
4653
- if (es5.isES5) {
4654
- var desc = Object.getOwnPropertyDescriptor(obj, key);
4655
-
4656
- if (desc != null) {
4657
- return desc.get == null && desc.set == null
4658
- ? desc.value
4659
- : defaultValue;
4660
- }
4661
- } else {
4662
- return {}.hasOwnProperty.call(obj, key) ? obj[key] : undefined;
4663
- }
4664
- }
4665
-
4666
- function notEnumerableProp(obj, name, value) {
4667
- if (isPrimitive(obj)) return obj;
4668
- var descriptor = {
4669
- value: value,
4670
- configurable: true,
4671
- enumerable: false,
4672
- writable: true
4673
- };
4674
- es5.defineProperty(obj, name, descriptor);
4675
- return obj;
4676
- }
4677
-
4678
- function thrower(r) {
4679
- throw r;
4680
- }
4681
-
4682
- var inheritedDataKeys = (function() {
4683
- var excludedPrototypes = [
4684
- Array.prototype,
4685
- Object.prototype,
4686
- Function.prototype
4687
- ];
4688
-
4689
- var isExcludedProto = function(val) {
4690
- for (var i = 0; i < excludedPrototypes.length; ++i) {
4691
- if (excludedPrototypes[i] === val) {
4692
- return true;
4693
- }
4694
- }
4695
- return false;
4696
- };
4697
-
4698
- if (es5.isES5) {
4699
- var getKeys = Object.getOwnPropertyNames;
4700
- return function(obj) {
4701
- var ret = [];
4702
- var visitedKeys = Object.create(null);
4703
- while (obj != null && !isExcludedProto(obj)) {
4704
- var keys;
4705
- try {
4706
- keys = getKeys(obj);
4707
- } catch (e) {
4708
- return ret;
4709
- }
4710
- for (var i = 0; i < keys.length; ++i) {
4711
- var key = keys[i];
4712
- if (visitedKeys[key]) continue;
4713
- visitedKeys[key] = true;
4714
- var desc = Object.getOwnPropertyDescriptor(obj, key);
4715
- if (desc != null && desc.get == null && desc.set == null) {
4716
- ret.push(key);
4717
- }
4718
- }
4719
- obj = es5.getPrototypeOf(obj);
4720
- }
4721
- return ret;
4722
- };
4723
- } else {
4724
- var hasProp = {}.hasOwnProperty;
4725
- return function(obj) {
4726
- if (isExcludedProto(obj)) return [];
4727
- var ret = [];
4728
-
4729
- /*jshint forin:false */
4730
- enumeration: for (var key in obj) {
4731
- if (hasProp.call(obj, key)) {
4732
- ret.push(key);
4733
- } else {
4734
- for (var i = 0; i < excludedPrototypes.length; ++i) {
4735
- if (hasProp.call(excludedPrototypes[i], key)) {
4736
- continue enumeration;
4737
- }
4738
- }
4739
- ret.push(key);
4740
- }
4741
- }
4742
- return ret;
4743
- };
4744
- }
4745
-
4746
- })();
4747
-
4748
- var thisAssignmentPattern = /this\s*\.\s*\S+\s*=/;
4749
- function isClass(fn) {
4750
- try {
4751
- if (typeof fn === "function") {
4752
- var keys = es5.names(fn.prototype);
4753
-
4754
- var hasMethods = es5.isES5 && keys.length > 1;
4755
- var hasMethodsOtherThanConstructor = keys.length > 0 &&
4756
- !(keys.length === 1 && keys[0] === "constructor");
4757
- var hasThisAssignmentAndStaticMethods =
4758
- thisAssignmentPattern.test(fn + "") && es5.names(fn).length > 0;
4759
-
4760
- if (hasMethods || hasMethodsOtherThanConstructor ||
4761
- hasThisAssignmentAndStaticMethods) {
4762
- return true;
4763
- }
4764
- }
4765
- return false;
4766
- } catch (e) {
4767
- return false;
4768
- }
4769
- }
4770
-
4771
- function toFastProperties(obj) {
4772
- /*jshint -W027,-W055,-W031*/
4773
- function f() {}
4774
- f.prototype = obj;
4775
- var l = 8;
4776
- while (l--) new f();
4777
- return obj;
4778
- eval(obj);
4779
- }
4780
-
4781
- var rident = /^[a-z$_][a-z$_0-9]*$/i;
4782
- function isIdentifier(str) {
4783
- return rident.test(str);
4784
- }
4785
-
4786
- function filledRange(count, prefix, suffix) {
4787
- var ret = new Array(count);
4788
- for(var i = 0; i < count; ++i) {
4789
- ret[i] = prefix + i + suffix;
4790
- }
4791
- return ret;
4792
- }
4793
-
4794
- function safeToString(obj) {
4795
- try {
4796
- return obj + "";
4797
- } catch (e) {
4798
- return "[no string representation]";
4799
- }
4800
- }
4801
-
4802
- function markAsOriginatingFromRejection(e) {
4803
- try {
4804
- notEnumerableProp(e, "isOperational", true);
4805
- }
4806
- catch(ignore) {}
4807
- }
4808
-
4809
- function originatesFromRejection(e) {
4810
- if (e == null) return false;
4811
- return ((e instanceof Error["__BluebirdErrorTypes__"].OperationalError) ||
4812
- e["isOperational"] === true);
4813
- }
4814
-
4815
- function canAttachTrace(obj) {
4816
- return obj instanceof Error && es5.propertyIsWritable(obj, "stack");
4817
- }
4818
-
4819
- var ensureErrorObject = (function() {
4820
- if (!("stack" in new Error())) {
4821
- return function(value) {
4822
- if (canAttachTrace(value)) return value;
4823
- try {throw new Error(safeToString(value));}
4824
- catch(err) {return err;}
4825
- };
4826
- } else {
4827
- return function(value) {
4828
- if (canAttachTrace(value)) return value;
4829
- return new Error(safeToString(value));
4830
- };
4831
- }
4832
- })();
4833
-
4834
- function classString(obj) {
4835
- return {}.toString.call(obj);
4836
- }
4837
-
4838
- function copyDescriptors(from, to, filter) {
4839
- var keys = es5.names(from);
4840
- for (var i = 0; i < keys.length; ++i) {
4841
- var key = keys[i];
4842
- if (filter(key)) {
4843
- try {
4844
- es5.defineProperty(to, key, es5.getDescriptor(from, key));
4845
- } catch (ignore) {}
4846
- }
4847
- }
4848
- }
4849
-
4850
- var ret = {
4851
- isClass: isClass,
4852
- isIdentifier: isIdentifier,
4853
- inheritedDataKeys: inheritedDataKeys,
4854
- getDataPropertyOrDefault: getDataPropertyOrDefault,
4855
- thrower: thrower,
4856
- isArray: es5.isArray,
4857
- haveGetters: haveGetters,
4858
- notEnumerableProp: notEnumerableProp,
4859
- isPrimitive: isPrimitive,
4860
- isObject: isObject,
4861
- canEvaluate: canEvaluate,
4862
- errorObj: errorObj,
4863
- tryCatch: tryCatch,
4864
- inherits: inherits,
4865
- withAppended: withAppended,
4866
- maybeWrapAsError: maybeWrapAsError,
4867
- toFastProperties: toFastProperties,
4868
- filledRange: filledRange,
4869
- toString: safeToString,
4870
- canAttachTrace: canAttachTrace,
4871
- ensureErrorObject: ensureErrorObject,
4872
- originatesFromRejection: originatesFromRejection,
4873
- markAsOriginatingFromRejection: markAsOriginatingFromRejection,
4874
- classString: classString,
4875
- copyDescriptors: copyDescriptors,
4876
- hasDevTools: typeof chrome !== "undefined" && chrome &&
4877
- typeof chrome.loadTimes === "function",
4878
- isNode: typeof process !== "undefined" &&
4879
- classString(process).toLowerCase() === "[object process]"
4880
- };
4881
- ret.isRecentNode = ret.isNode && (function() {
4882
- var version = process.versions.node.split(".").map(Number);
4883
- return (version[0] === 0 && version[1] > 10) || (version[0] > 0);
4884
- })();
4885
-
4886
- if (ret.isNode) ret.toFastProperties(process);
4887
-
4888
- try {throw new Error(); } catch (e) {ret.lastLineError = e;}
4889
- module.exports = ret;
4890
-
4891
- },{"./es5.js":14}]},{},[4])(4)
4892
- }); ;if (typeof window !== 'undefined' && window !== null) { window.P = window.Promise; } else if (typeof self !== 'undefined' && self !== null) { self.P = self.Promise; }