browsed 0.2.8 → 0.3.4

Sign up to get free protection for your applications and to get access to all the features.
Files changed (163) 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/browser.rb +2 -2
  6. data/lib/browsed/chrome.rb +2 -2
  7. data/lib/browsed/client.rb +4 -3
  8. data/lib/browsed/firefox.rb +2 -2
  9. data/lib/browsed/version.rb +1 -1
  10. metadata +13 -166
  11. data/lib/browsed/proxies/proxy-chain-server/node_modules/.bin/portastic +0 -1
  12. data/lib/browsed/proxies/proxy-chain-server/node_modules/bluebird/LICENSE +0 -21
  13. data/lib/browsed/proxies/proxy-chain-server/node_modules/bluebird/README.md +0 -57
  14. data/lib/browsed/proxies/proxy-chain-server/node_modules/bluebird/changelog.md +0 -1
  15. data/lib/browsed/proxies/proxy-chain-server/node_modules/bluebird/js/browser/bluebird.core.js +0 -3824
  16. data/lib/browsed/proxies/proxy-chain-server/node_modules/bluebird/js/browser/bluebird.core.min.js +0 -31
  17. data/lib/browsed/proxies/proxy-chain-server/node_modules/bluebird/js/browser/bluebird.js +0 -5666
  18. data/lib/browsed/proxies/proxy-chain-server/node_modules/bluebird/js/browser/bluebird.min.js +0 -31
  19. data/lib/browsed/proxies/proxy-chain-server/node_modules/bluebird/js/release/any.js +0 -21
  20. data/lib/browsed/proxies/proxy-chain-server/node_modules/bluebird/js/release/assert.js +0 -55
  21. data/lib/browsed/proxies/proxy-chain-server/node_modules/bluebird/js/release/async.js +0 -165
  22. data/lib/browsed/proxies/proxy-chain-server/node_modules/bluebird/js/release/bind.js +0 -67
  23. data/lib/browsed/proxies/proxy-chain-server/node_modules/bluebird/js/release/bluebird.js +0 -11
  24. data/lib/browsed/proxies/proxy-chain-server/node_modules/bluebird/js/release/call_get.js +0 -123
  25. data/lib/browsed/proxies/proxy-chain-server/node_modules/bluebird/js/release/cancel.js +0 -129
  26. data/lib/browsed/proxies/proxy-chain-server/node_modules/bluebird/js/release/catch_filter.js +0 -42
  27. data/lib/browsed/proxies/proxy-chain-server/node_modules/bluebird/js/release/context.js +0 -69
  28. data/lib/browsed/proxies/proxy-chain-server/node_modules/bluebird/js/release/debuggability.js +0 -934
  29. data/lib/browsed/proxies/proxy-chain-server/node_modules/bluebird/js/release/direct_resolve.js +0 -46
  30. data/lib/browsed/proxies/proxy-chain-server/node_modules/bluebird/js/release/each.js +0 -30
  31. data/lib/browsed/proxies/proxy-chain-server/node_modules/bluebird/js/release/errors.js +0 -116
  32. data/lib/browsed/proxies/proxy-chain-server/node_modules/bluebird/js/release/es5.js +0 -80
  33. data/lib/browsed/proxies/proxy-chain-server/node_modules/bluebird/js/release/filter.js +0 -12
  34. data/lib/browsed/proxies/proxy-chain-server/node_modules/bluebird/js/release/finally.js +0 -146
  35. data/lib/browsed/proxies/proxy-chain-server/node_modules/bluebird/js/release/generators.js +0 -223
  36. data/lib/browsed/proxies/proxy-chain-server/node_modules/bluebird/js/release/join.js +0 -168
  37. data/lib/browsed/proxies/proxy-chain-server/node_modules/bluebird/js/release/map.js +0 -168
  38. data/lib/browsed/proxies/proxy-chain-server/node_modules/bluebird/js/release/method.js +0 -55
  39. data/lib/browsed/proxies/proxy-chain-server/node_modules/bluebird/js/release/nodeback.js +0 -51
  40. data/lib/browsed/proxies/proxy-chain-server/node_modules/bluebird/js/release/nodeify.js +0 -58
  41. data/lib/browsed/proxies/proxy-chain-server/node_modules/bluebird/js/release/promise.js +0 -789
  42. data/lib/browsed/proxies/proxy-chain-server/node_modules/bluebird/js/release/promise_array.js +0 -185
  43. data/lib/browsed/proxies/proxy-chain-server/node_modules/bluebird/js/release/promisify.js +0 -314
  44. data/lib/browsed/proxies/proxy-chain-server/node_modules/bluebird/js/release/props.js +0 -118
  45. data/lib/browsed/proxies/proxy-chain-server/node_modules/bluebird/js/release/queue.js +0 -73
  46. data/lib/browsed/proxies/proxy-chain-server/node_modules/bluebird/js/release/race.js +0 -49
  47. data/lib/browsed/proxies/proxy-chain-server/node_modules/bluebird/js/release/reduce.js +0 -172
  48. data/lib/browsed/proxies/proxy-chain-server/node_modules/bluebird/js/release/schedule.js +0 -62
  49. data/lib/browsed/proxies/proxy-chain-server/node_modules/bluebird/js/release/settle.js +0 -43
  50. data/lib/browsed/proxies/proxy-chain-server/node_modules/bluebird/js/release/some.js +0 -148
  51. data/lib/browsed/proxies/proxy-chain-server/node_modules/bluebird/js/release/synchronous_inspection.js +0 -103
  52. data/lib/browsed/proxies/proxy-chain-server/node_modules/bluebird/js/release/thenables.js +0 -86
  53. data/lib/browsed/proxies/proxy-chain-server/node_modules/bluebird/js/release/timers.js +0 -93
  54. data/lib/browsed/proxies/proxy-chain-server/node_modules/bluebird/js/release/using.js +0 -226
  55. data/lib/browsed/proxies/proxy-chain-server/node_modules/bluebird/js/release/util.js +0 -389
  56. data/lib/browsed/proxies/proxy-chain-server/node_modules/bluebird/package.json +0 -102
  57. data/lib/browsed/proxies/proxy-chain-server/node_modules/commander/CHANGELOG.md +0 -408
  58. data/lib/browsed/proxies/proxy-chain-server/node_modules/commander/LICENSE +0 -22
  59. data/lib/browsed/proxies/proxy-chain-server/node_modules/commander/Readme.md +0 -428
  60. data/lib/browsed/proxies/proxy-chain-server/node_modules/commander/index.js +0 -1224
  61. data/lib/browsed/proxies/proxy-chain-server/node_modules/commander/package.json +0 -70
  62. data/lib/browsed/proxies/proxy-chain-server/node_modules/commander/typings/index.d.ts +0 -310
  63. data/lib/browsed/proxies/proxy-chain-server/node_modules/debug/.coveralls.yml +0 -1
  64. data/lib/browsed/proxies/proxy-chain-server/node_modules/debug/.eslintrc +0 -11
  65. data/lib/browsed/proxies/proxy-chain-server/node_modules/debug/.npmignore +0 -9
  66. data/lib/browsed/proxies/proxy-chain-server/node_modules/debug/.travis.yml +0 -14
  67. data/lib/browsed/proxies/proxy-chain-server/node_modules/debug/CHANGELOG.md +0 -362
  68. data/lib/browsed/proxies/proxy-chain-server/node_modules/debug/LICENSE +0 -19
  69. data/lib/browsed/proxies/proxy-chain-server/node_modules/debug/Makefile +0 -50
  70. data/lib/browsed/proxies/proxy-chain-server/node_modules/debug/README.md +0 -312
  71. data/lib/browsed/proxies/proxy-chain-server/node_modules/debug/component.json +0 -19
  72. data/lib/browsed/proxies/proxy-chain-server/node_modules/debug/karma.conf.js +0 -70
  73. data/lib/browsed/proxies/proxy-chain-server/node_modules/debug/node.js +0 -1
  74. data/lib/browsed/proxies/proxy-chain-server/node_modules/debug/package.json +0 -88
  75. data/lib/browsed/proxies/proxy-chain-server/node_modules/debug/src/browser.js +0 -185
  76. data/lib/browsed/proxies/proxy-chain-server/node_modules/debug/src/debug.js +0 -202
  77. data/lib/browsed/proxies/proxy-chain-server/node_modules/debug/src/index.js +0 -10
  78. data/lib/browsed/proxies/proxy-chain-server/node_modules/debug/src/inspector-log.js +0 -15
  79. data/lib/browsed/proxies/proxy-chain-server/node_modules/debug/src/node.js +0 -248
  80. data/lib/browsed/proxies/proxy-chain-server/node_modules/ms/index.js +0 -152
  81. data/lib/browsed/proxies/proxy-chain-server/node_modules/ms/license.md +0 -21
  82. data/lib/browsed/proxies/proxy-chain-server/node_modules/ms/package.json +0 -69
  83. data/lib/browsed/proxies/proxy-chain-server/node_modules/ms/readme.md +0 -51
  84. data/lib/browsed/proxies/proxy-chain-server/node_modules/portastic/LICENSE +0 -13
  85. data/lib/browsed/proxies/proxy-chain-server/node_modules/portastic/README.md +0 -148
  86. data/lib/browsed/proxies/proxy-chain-server/node_modules/portastic/bin/portastic +0 -65
  87. data/lib/browsed/proxies/proxy-chain-server/node_modules/portastic/history.md +0 -7
  88. data/lib/browsed/proxies/proxy-chain-server/node_modules/portastic/index.js +0 -4
  89. data/lib/browsed/proxies/proxy-chain-server/node_modules/portastic/lib/monitor.js +0 -59
  90. data/lib/browsed/proxies/proxy-chain-server/node_modules/portastic/lib/portastic.js +0 -167
  91. data/lib/browsed/proxies/proxy-chain-server/node_modules/portastic/node_modules/bluebird/LICENSE +0 -21
  92. data/lib/browsed/proxies/proxy-chain-server/node_modules/portastic/node_modules/bluebird/README.md +0 -677
  93. data/lib/browsed/proxies/proxy-chain-server/node_modules/portastic/node_modules/bluebird/changelog.md +0 -1730
  94. data/lib/browsed/proxies/proxy-chain-server/node_modules/portastic/node_modules/bluebird/js/browser/bluebird.js +0 -4892
  95. data/lib/browsed/proxies/proxy-chain-server/node_modules/portastic/node_modules/bluebird/js/browser/bluebird.min.js +0 -31
  96. data/lib/browsed/proxies/proxy-chain-server/node_modules/portastic/node_modules/bluebird/js/main/any.js +0 -21
  97. data/lib/browsed/proxies/proxy-chain-server/node_modules/portastic/node_modules/bluebird/js/main/assert.js +0 -55
  98. data/lib/browsed/proxies/proxy-chain-server/node_modules/portastic/node_modules/bluebird/js/main/async.js +0 -150
  99. data/lib/browsed/proxies/proxy-chain-server/node_modules/portastic/node_modules/bluebird/js/main/bind.js +0 -72
  100. data/lib/browsed/proxies/proxy-chain-server/node_modules/portastic/node_modules/bluebird/js/main/bluebird.js +0 -11
  101. data/lib/browsed/proxies/proxy-chain-server/node_modules/portastic/node_modules/bluebird/js/main/call_get.js +0 -123
  102. data/lib/browsed/proxies/proxy-chain-server/node_modules/portastic/node_modules/bluebird/js/main/cancel.js +0 -48
  103. data/lib/browsed/proxies/proxy-chain-server/node_modules/portastic/node_modules/bluebird/js/main/captured_trace.js +0 -493
  104. data/lib/browsed/proxies/proxy-chain-server/node_modules/portastic/node_modules/bluebird/js/main/catch_filter.js +0 -66
  105. data/lib/browsed/proxies/proxy-chain-server/node_modules/portastic/node_modules/bluebird/js/main/context.js +0 -38
  106. data/lib/browsed/proxies/proxy-chain-server/node_modules/portastic/node_modules/bluebird/js/main/debuggability.js +0 -162
  107. data/lib/browsed/proxies/proxy-chain-server/node_modules/portastic/node_modules/bluebird/js/main/direct_resolve.js +0 -63
  108. data/lib/browsed/proxies/proxy-chain-server/node_modules/portastic/node_modules/bluebird/js/main/each.js +0 -12
  109. data/lib/browsed/proxies/proxy-chain-server/node_modules/portastic/node_modules/bluebird/js/main/errors.js +0 -111
  110. data/lib/browsed/proxies/proxy-chain-server/node_modules/portastic/node_modules/bluebird/js/main/es5.js +0 -80
  111. data/lib/browsed/proxies/proxy-chain-server/node_modules/portastic/node_modules/bluebird/js/main/filter.js +0 -12
  112. data/lib/browsed/proxies/proxy-chain-server/node_modules/portastic/node_modules/bluebird/js/main/finally.js +0 -98
  113. data/lib/browsed/proxies/proxy-chain-server/node_modules/portastic/node_modules/bluebird/js/main/generators.js +0 -136
  114. data/lib/browsed/proxies/proxy-chain-server/node_modules/portastic/node_modules/bluebird/js/main/join.js +0 -107
  115. data/lib/browsed/proxies/proxy-chain-server/node_modules/portastic/node_modules/bluebird/js/main/map.js +0 -133
  116. data/lib/browsed/proxies/proxy-chain-server/node_modules/portastic/node_modules/bluebird/js/main/method.js +0 -44
  117. data/lib/browsed/proxies/proxy-chain-server/node_modules/portastic/node_modules/bluebird/js/main/nodeify.js +0 -59
  118. data/lib/browsed/proxies/proxy-chain-server/node_modules/portastic/node_modules/bluebird/js/main/progress.js +0 -76
  119. data/lib/browsed/proxies/proxy-chain-server/node_modules/portastic/node_modules/bluebird/js/main/promise.js +0 -759
  120. data/lib/browsed/proxies/proxy-chain-server/node_modules/portastic/node_modules/bluebird/js/main/promise_array.js +0 -142
  121. data/lib/browsed/proxies/proxy-chain-server/node_modules/portastic/node_modules/bluebird/js/main/promise_resolver.js +0 -123
  122. data/lib/browsed/proxies/proxy-chain-server/node_modules/portastic/node_modules/bluebird/js/main/promisify.js +0 -307
  123. data/lib/browsed/proxies/proxy-chain-server/node_modules/portastic/node_modules/bluebird/js/main/props.js +0 -79
  124. data/lib/browsed/proxies/proxy-chain-server/node_modules/portastic/node_modules/bluebird/js/main/queue.js +0 -90
  125. data/lib/browsed/proxies/proxy-chain-server/node_modules/portastic/node_modules/bluebird/js/main/race.js +0 -47
  126. data/lib/browsed/proxies/proxy-chain-server/node_modules/portastic/node_modules/bluebird/js/main/reduce.js +0 -148
  127. data/lib/browsed/proxies/proxy-chain-server/node_modules/portastic/node_modules/bluebird/js/main/schedule.js +0 -35
  128. data/lib/browsed/proxies/proxy-chain-server/node_modules/portastic/node_modules/bluebird/js/main/settle.js +0 -40
  129. data/lib/browsed/proxies/proxy-chain-server/node_modules/portastic/node_modules/bluebird/js/main/some.js +0 -125
  130. data/lib/browsed/proxies/proxy-chain-server/node_modules/portastic/node_modules/bluebird/js/main/synchronous_inspection.js +0 -94
  131. data/lib/browsed/proxies/proxy-chain-server/node_modules/portastic/node_modules/bluebird/js/main/thenables.js +0 -84
  132. data/lib/browsed/proxies/proxy-chain-server/node_modules/portastic/node_modules/bluebird/js/main/timers.js +0 -64
  133. data/lib/browsed/proxies/proxy-chain-server/node_modules/portastic/node_modules/bluebird/js/main/using.js +0 -213
  134. data/lib/browsed/proxies/proxy-chain-server/node_modules/portastic/node_modules/bluebird/js/main/util.js +0 -321
  135. data/lib/browsed/proxies/proxy-chain-server/node_modules/portastic/node_modules/bluebird/package.json +0 -103
  136. data/lib/browsed/proxies/proxy-chain-server/node_modules/portastic/package.json +0 -69
  137. data/lib/browsed/proxies/proxy-chain-server/node_modules/proxy-chain/CHANGELOG.md +0 -109
  138. data/lib/browsed/proxies/proxy-chain-server/node_modules/proxy-chain/LICENSE +0 -201
  139. data/lib/browsed/proxies/proxy-chain-server/node_modules/proxy-chain/README.md +0 -278
  140. data/lib/browsed/proxies/proxy-chain-server/node_modules/proxy-chain/build/anonymize_proxy.js +0 -100
  141. data/lib/browsed/proxies/proxy-chain-server/node_modules/proxy-chain/build/handler_base.js +0 -319
  142. data/lib/browsed/proxies/proxy-chain-server/node_modules/proxy-chain/build/handler_custom_response.js +0 -96
  143. data/lib/browsed/proxies/proxy-chain-server/node_modules/proxy-chain/build/handler_forward.js +0 -173
  144. data/lib/browsed/proxies/proxy-chain-server/node_modules/proxy-chain/build/handler_tunnel_chain.js +0 -132
  145. data/lib/browsed/proxies/proxy-chain-server/node_modules/proxy-chain/build/handler_tunnel_direct.js +0 -89
  146. data/lib/browsed/proxies/proxy-chain-server/node_modules/proxy-chain/build/handler_tunnel_tcp_chain.js +0 -271
  147. data/lib/browsed/proxies/proxy-chain-server/node_modules/proxy-chain/build/index.js +0 -26
  148. data/lib/browsed/proxies/proxy-chain-server/node_modules/proxy-chain/build/run_locally.js +0 -66
  149. data/lib/browsed/proxies/proxy-chain-server/node_modules/proxy-chain/build/server.js +0 -595
  150. data/lib/browsed/proxies/proxy-chain-server/node_modules/proxy-chain/build/tcp_tunnel.js +0 -138
  151. data/lib/browsed/proxies/proxy-chain-server/node_modules/proxy-chain/build/testing_tcp_service.js +0 -37
  152. data/lib/browsed/proxies/proxy-chain-server/node_modules/proxy-chain/build/tools.js +0 -220
  153. data/lib/browsed/proxies/proxy-chain-server/node_modules/proxy-chain/package.json +0 -104
  154. data/lib/browsed/proxies/proxy-chain-server/node_modules/underscore/LICENSE +0 -23
  155. data/lib/browsed/proxies/proxy-chain-server/node_modules/underscore/README.md +0 -28
  156. data/lib/browsed/proxies/proxy-chain-server/node_modules/underscore/package.json +0 -81
  157. data/lib/browsed/proxies/proxy-chain-server/node_modules/underscore/underscore-min.js +0 -5
  158. data/lib/browsed/proxies/proxy-chain-server/node_modules/underscore/underscore-min.js.map +0 -1
  159. data/lib/browsed/proxies/proxy-chain-server/node_modules/underscore/underscore.js +0 -1692
  160. data/lib/browsed/proxies/proxy-chain-server/package-lock.json +0 -63
  161. data/lib/browsed/proxies/proxy-chain-server/package.json +0 -15
  162. data/lib/browsed/proxies/proxy-chain-server/server.js +0 -25
  163. data/lib/browsed/proxies/proxy_chain.rb +0 -39
@@ -1,142 +0,0 @@
1
- "use strict";
2
- module.exports = function(Promise, INTERNAL, tryConvertToPromise,
3
- apiRejection) {
4
- var util = require("./util.js");
5
- var isArray = util.isArray;
6
-
7
- function toResolutionValue(val) {
8
- switch(val) {
9
- case -2: return [];
10
- case -3: return {};
11
- }
12
- }
13
-
14
- function PromiseArray(values) {
15
- var promise = this._promise = new Promise(INTERNAL);
16
- var parent;
17
- if (values instanceof Promise) {
18
- parent = values;
19
- promise._propagateFrom(parent, 1 | 4);
20
- }
21
- this._values = values;
22
- this._length = 0;
23
- this._totalResolved = 0;
24
- this._init(undefined, -2);
25
- }
26
- PromiseArray.prototype.length = function () {
27
- return this._length;
28
- };
29
-
30
- PromiseArray.prototype.promise = function () {
31
- return this._promise;
32
- };
33
-
34
- PromiseArray.prototype._init = function init(_, resolveValueIfEmpty) {
35
- var values = tryConvertToPromise(this._values, this._promise);
36
- if (values instanceof Promise) {
37
- values = values._target();
38
- this._values = values;
39
- if (values._isFulfilled()) {
40
- values = values._value();
41
- if (!isArray(values)) {
42
- var err = new Promise.TypeError("expecting an array, a promise or a thenable\u000a\u000a See http://goo.gl/s8MMhc\u000a");
43
- this.__hardReject__(err);
44
- return;
45
- }
46
- } else if (values._isPending()) {
47
- values._then(
48
- init,
49
- this._reject,
50
- undefined,
51
- this,
52
- resolveValueIfEmpty
53
- );
54
- return;
55
- } else {
56
- this._reject(values._reason());
57
- return;
58
- }
59
- } else if (!isArray(values)) {
60
- this._promise._reject(apiRejection("expecting an array, a promise or a thenable\u000a\u000a See http://goo.gl/s8MMhc\u000a")._reason());
61
- return;
62
- }
63
-
64
- if (values.length === 0) {
65
- if (resolveValueIfEmpty === -5) {
66
- this._resolveEmptyArray();
67
- }
68
- else {
69
- this._resolve(toResolutionValue(resolveValueIfEmpty));
70
- }
71
- return;
72
- }
73
- var len = this.getActualLength(values.length);
74
- this._length = len;
75
- this._values = this.shouldCopyValues() ? new Array(len) : this._values;
76
- var promise = this._promise;
77
- for (var i = 0; i < len; ++i) {
78
- var isResolved = this._isResolved();
79
- var maybePromise = tryConvertToPromise(values[i], promise);
80
- if (maybePromise instanceof Promise) {
81
- maybePromise = maybePromise._target();
82
- if (isResolved) {
83
- maybePromise._ignoreRejections();
84
- } else if (maybePromise._isPending()) {
85
- maybePromise._proxyPromiseArray(this, i);
86
- } else if (maybePromise._isFulfilled()) {
87
- this._promiseFulfilled(maybePromise._value(), i);
88
- } else {
89
- this._promiseRejected(maybePromise._reason(), i);
90
- }
91
- } else if (!isResolved) {
92
- this._promiseFulfilled(maybePromise, i);
93
- }
94
- }
95
- };
96
-
97
- PromiseArray.prototype._isResolved = function () {
98
- return this._values === null;
99
- };
100
-
101
- PromiseArray.prototype._resolve = function (value) {
102
- this._values = null;
103
- this._promise._fulfill(value);
104
- };
105
-
106
- PromiseArray.prototype.__hardReject__ =
107
- PromiseArray.prototype._reject = function (reason) {
108
- this._values = null;
109
- this._promise._rejectCallback(reason, false, true);
110
- };
111
-
112
- PromiseArray.prototype._promiseProgressed = function (progressValue, index) {
113
- this._promise._progress({
114
- index: index,
115
- value: progressValue
116
- });
117
- };
118
-
119
-
120
- PromiseArray.prototype._promiseFulfilled = function (value, index) {
121
- this._values[index] = value;
122
- var totalResolved = ++this._totalResolved;
123
- if (totalResolved >= this._length) {
124
- this._resolve(this._values);
125
- }
126
- };
127
-
128
- PromiseArray.prototype._promiseRejected = function (reason, index) {
129
- this._totalResolved++;
130
- this._reject(reason);
131
- };
132
-
133
- PromiseArray.prototype.shouldCopyValues = function () {
134
- return true;
135
- };
136
-
137
- PromiseArray.prototype.getActualLength = function (len) {
138
- return len;
139
- };
140
-
141
- return PromiseArray;
142
- };
@@ -1,123 +0,0 @@
1
- "use strict";
2
- var util = require("./util.js");
3
- var maybeWrapAsError = util.maybeWrapAsError;
4
- var errors = require("./errors.js");
5
- var TimeoutError = errors.TimeoutError;
6
- var OperationalError = errors.OperationalError;
7
- var haveGetters = util.haveGetters;
8
- var es5 = require("./es5.js");
9
-
10
- function isUntypedError(obj) {
11
- return obj instanceof Error &&
12
- es5.getPrototypeOf(obj) === Error.prototype;
13
- }
14
-
15
- var rErrorKey = /^(?:name|message|stack|cause)$/;
16
- function wrapAsOperationalError(obj) {
17
- var ret;
18
- if (isUntypedError(obj)) {
19
- ret = new OperationalError(obj);
20
- ret.name = obj.name;
21
- ret.message = obj.message;
22
- ret.stack = obj.stack;
23
- var keys = es5.keys(obj);
24
- for (var i = 0; i < keys.length; ++i) {
25
- var key = keys[i];
26
- if (!rErrorKey.test(key)) {
27
- ret[key] = obj[key];
28
- }
29
- }
30
- return ret;
31
- }
32
- util.markAsOriginatingFromRejection(obj);
33
- return obj;
34
- }
35
-
36
- function nodebackForPromise(promise) {
37
- return function(err, value) {
38
- if (promise === null) return;
39
-
40
- if (err) {
41
- var wrapped = wrapAsOperationalError(maybeWrapAsError(err));
42
- promise._attachExtraTrace(wrapped);
43
- promise._reject(wrapped);
44
- } else if (arguments.length > 2) {
45
- var $_len = arguments.length;var args = new Array($_len - 1); for(var $_i = 1; $_i < $_len; ++$_i) {args[$_i - 1] = arguments[$_i];}
46
- promise._fulfill(args);
47
- } else {
48
- promise._fulfill(value);
49
- }
50
-
51
- promise = null;
52
- };
53
- }
54
-
55
-
56
- var PromiseResolver;
57
- if (!haveGetters) {
58
- PromiseResolver = function (promise) {
59
- this.promise = promise;
60
- this.asCallback = nodebackForPromise(promise);
61
- this.callback = this.asCallback;
62
- };
63
- }
64
- else {
65
- PromiseResolver = function (promise) {
66
- this.promise = promise;
67
- };
68
- }
69
- if (haveGetters) {
70
- var prop = {
71
- get: function() {
72
- return nodebackForPromise(this.promise);
73
- }
74
- };
75
- es5.defineProperty(PromiseResolver.prototype, "asCallback", prop);
76
- es5.defineProperty(PromiseResolver.prototype, "callback", prop);
77
- }
78
-
79
- PromiseResolver._nodebackForPromise = nodebackForPromise;
80
-
81
- PromiseResolver.prototype.toString = function () {
82
- return "[object PromiseResolver]";
83
- };
84
-
85
- PromiseResolver.prototype.resolve =
86
- PromiseResolver.prototype.fulfill = function (value) {
87
- if (!(this instanceof PromiseResolver)) {
88
- 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");
89
- }
90
- this.promise._resolveCallback(value);
91
- };
92
-
93
- PromiseResolver.prototype.reject = function (reason) {
94
- if (!(this instanceof PromiseResolver)) {
95
- 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");
96
- }
97
- this.promise._rejectCallback(reason);
98
- };
99
-
100
- PromiseResolver.prototype.progress = function (value) {
101
- if (!(this instanceof PromiseResolver)) {
102
- 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");
103
- }
104
- this.promise._progress(value);
105
- };
106
-
107
- PromiseResolver.prototype.cancel = function (err) {
108
- this.promise.cancel(err);
109
- };
110
-
111
- PromiseResolver.prototype.timeout = function () {
112
- this.reject(new TimeoutError("timeout"));
113
- };
114
-
115
- PromiseResolver.prototype.isResolved = function () {
116
- return this.promise.isResolved();
117
- };
118
-
119
- PromiseResolver.prototype.toJSON = function () {
120
- return this.promise.toJSON();
121
- };
122
-
123
- module.exports = PromiseResolver;
@@ -1,307 +0,0 @@
1
- "use strict";
2
- module.exports = function(Promise, INTERNAL) {
3
- var THIS = {};
4
- var util = require("./util.js");
5
- var nodebackForPromise = require("./promise_resolver.js")
6
- ._nodebackForPromise;
7
- var withAppended = util.withAppended;
8
- var maybeWrapAsError = util.maybeWrapAsError;
9
- var canEvaluate = util.canEvaluate;
10
- var TypeError = require("./errors").TypeError;
11
- var defaultSuffix = "Async";
12
- var defaultPromisified = {__isPromisified__: true};
13
- var noCopyProps = [
14
- "arity", "length",
15
- "name",
16
- "arguments",
17
- "caller",
18
- "callee",
19
- "prototype",
20
- "__isPromisified__"
21
- ];
22
- var noCopyPropsPattern = new RegExp("^(?:" + noCopyProps.join("|") + ")$");
23
-
24
- var defaultFilter = function(name) {
25
- return util.isIdentifier(name) &&
26
- name.charAt(0) !== "_" &&
27
- name !== "constructor";
28
- };
29
-
30
- function propsFilter(key) {
31
- return !noCopyPropsPattern.test(key);
32
- }
33
-
34
- function isPromisified(fn) {
35
- try {
36
- return fn.__isPromisified__ === true;
37
- }
38
- catch (e) {
39
- return false;
40
- }
41
- }
42
-
43
- function hasPromisified(obj, key, suffix) {
44
- var val = util.getDataPropertyOrDefault(obj, key + suffix,
45
- defaultPromisified);
46
- return val ? isPromisified(val) : false;
47
- }
48
- function checkValid(ret, suffix, suffixRegexp) {
49
- for (var i = 0; i < ret.length; i += 2) {
50
- var key = ret[i];
51
- if (suffixRegexp.test(key)) {
52
- var keyWithoutAsyncSuffix = key.replace(suffixRegexp, "");
53
- for (var j = 0; j < ret.length; j += 2) {
54
- if (ret[j] === keyWithoutAsyncSuffix) {
55
- throw new TypeError("Cannot promisify an API that has normal methods with '%s'-suffix\u000a\u000a See http://goo.gl/iWrZbw\u000a"
56
- .replace("%s", suffix));
57
- }
58
- }
59
- }
60
- }
61
- }
62
-
63
- function promisifiableMethods(obj, suffix, suffixRegexp, filter) {
64
- var keys = util.inheritedDataKeys(obj);
65
- var ret = [];
66
- for (var i = 0; i < keys.length; ++i) {
67
- var key = keys[i];
68
- var value = obj[key];
69
- var passesDefaultFilter = filter === defaultFilter
70
- ? true : defaultFilter(key, value, obj);
71
- if (typeof value === "function" &&
72
- !isPromisified(value) &&
73
- !hasPromisified(obj, key, suffix) &&
74
- filter(key, value, obj, passesDefaultFilter)) {
75
- ret.push(key, value);
76
- }
77
- }
78
- checkValid(ret, suffix, suffixRegexp);
79
- return ret;
80
- }
81
-
82
- var escapeIdentRegex = function(str) {
83
- return str.replace(/([$])/, "\\$");
84
- };
85
-
86
- var makeNodePromisifiedEval;
87
- if (!false) {
88
- var switchCaseArgumentOrder = function(likelyArgumentCount) {
89
- var ret = [likelyArgumentCount];
90
- var min = Math.max(0, likelyArgumentCount - 1 - 3);
91
- for(var i = likelyArgumentCount - 1; i >= min; --i) {
92
- ret.push(i);
93
- }
94
- for(var i = likelyArgumentCount + 1; i <= 3; ++i) {
95
- ret.push(i);
96
- }
97
- return ret;
98
- };
99
-
100
- var argumentSequence = function(argumentCount) {
101
- return util.filledRange(argumentCount, "_arg", "");
102
- };
103
-
104
- var parameterDeclaration = function(parameterCount) {
105
- return util.filledRange(
106
- Math.max(parameterCount, 3), "_arg", "");
107
- };
108
-
109
- var parameterCount = function(fn) {
110
- if (typeof fn.length === "number") {
111
- return Math.max(Math.min(fn.length, 1023 + 1), 0);
112
- }
113
- return 0;
114
- };
115
-
116
- makeNodePromisifiedEval =
117
- function(callback, receiver, originalName, fn) {
118
- var newParameterCount = Math.max(0, parameterCount(fn) - 1);
119
- var argumentOrder = switchCaseArgumentOrder(newParameterCount);
120
- var shouldProxyThis = typeof callback === "string" || receiver === THIS;
121
-
122
- function generateCallForArgumentCount(count) {
123
- var args = argumentSequence(count).join(", ");
124
- var comma = count > 0 ? ", " : "";
125
- var ret;
126
- if (shouldProxyThis) {
127
- ret = "ret = callback.call(this, {{args}}, nodeback); break;\n";
128
- } else {
129
- ret = receiver === undefined
130
- ? "ret = callback({{args}}, nodeback); break;\n"
131
- : "ret = callback.call(receiver, {{args}}, nodeback); break;\n";
132
- }
133
- return ret.replace("{{args}}", args).replace(", ", comma);
134
- }
135
-
136
- function generateArgumentSwitchCase() {
137
- var ret = "";
138
- for (var i = 0; i < argumentOrder.length; ++i) {
139
- ret += "case " + argumentOrder[i] +":" +
140
- generateCallForArgumentCount(argumentOrder[i]);
141
- }
142
-
143
- ret += " \n\
144
- default: \n\
145
- var args = new Array(len + 1); \n\
146
- var i = 0; \n\
147
- for (var i = 0; i < len; ++i) { \n\
148
- args[i] = arguments[i]; \n\
149
- } \n\
150
- args[i] = nodeback; \n\
151
- [CodeForCall] \n\
152
- break; \n\
153
- ".replace("[CodeForCall]", (shouldProxyThis
154
- ? "ret = callback.apply(this, args);\n"
155
- : "ret = callback.apply(receiver, args);\n"));
156
- return ret;
157
- }
158
-
159
- var getFunctionCode = typeof callback === "string"
160
- ? ("this != null ? this['"+callback+"'] : fn")
161
- : "fn";
162
-
163
- return new Function("Promise",
164
- "fn",
165
- "receiver",
166
- "withAppended",
167
- "maybeWrapAsError",
168
- "nodebackForPromise",
169
- "tryCatch",
170
- "errorObj",
171
- "notEnumerableProp",
172
- "INTERNAL","'use strict'; \n\
173
- var ret = function (Parameters) { \n\
174
- 'use strict'; \n\
175
- var len = arguments.length; \n\
176
- var promise = new Promise(INTERNAL); \n\
177
- promise._captureStackTrace(); \n\
178
- var nodeback = nodebackForPromise(promise); \n\
179
- var ret; \n\
180
- var callback = tryCatch([GetFunctionCode]); \n\
181
- switch(len) { \n\
182
- [CodeForSwitchCase] \n\
183
- } \n\
184
- if (ret === errorObj) { \n\
185
- promise._rejectCallback(maybeWrapAsError(ret.e), true, true);\n\
186
- } \n\
187
- return promise; \n\
188
- }; \n\
189
- notEnumerableProp(ret, '__isPromisified__', true); \n\
190
- return ret; \n\
191
- "
192
- .replace("Parameters", parameterDeclaration(newParameterCount))
193
- .replace("[CodeForSwitchCase]", generateArgumentSwitchCase())
194
- .replace("[GetFunctionCode]", getFunctionCode))(
195
- Promise,
196
- fn,
197
- receiver,
198
- withAppended,
199
- maybeWrapAsError,
200
- nodebackForPromise,
201
- util.tryCatch,
202
- util.errorObj,
203
- util.notEnumerableProp,
204
- INTERNAL
205
- );
206
- };
207
- }
208
-
209
- function makeNodePromisifiedClosure(callback, receiver, _, fn) {
210
- var defaultThis = (function() {return this;})();
211
- var method = callback;
212
- if (typeof method === "string") {
213
- callback = fn;
214
- }
215
- function promisified() {
216
- var _receiver = receiver;
217
- if (receiver === THIS) _receiver = this;
218
- var promise = new Promise(INTERNAL);
219
- promise._captureStackTrace();
220
- var cb = typeof method === "string" && this !== defaultThis
221
- ? this[method] : callback;
222
- var fn = nodebackForPromise(promise);
223
- try {
224
- cb.apply(_receiver, withAppended(arguments, fn));
225
- } catch(e) {
226
- promise._rejectCallback(maybeWrapAsError(e), true, true);
227
- }
228
- return promise;
229
- }
230
- util.notEnumerableProp(promisified, "__isPromisified__", true);
231
- return promisified;
232
- }
233
-
234
- var makeNodePromisified = canEvaluate
235
- ? makeNodePromisifiedEval
236
- : makeNodePromisifiedClosure;
237
-
238
- function promisifyAll(obj, suffix, filter, promisifier) {
239
- var suffixRegexp = new RegExp(escapeIdentRegex(suffix) + "$");
240
- var methods =
241
- promisifiableMethods(obj, suffix, suffixRegexp, filter);
242
-
243
- for (var i = 0, len = methods.length; i < len; i+= 2) {
244
- var key = methods[i];
245
- var fn = methods[i+1];
246
- var promisifiedKey = key + suffix;
247
- if (promisifier === makeNodePromisified) {
248
- obj[promisifiedKey] =
249
- makeNodePromisified(key, THIS, key, fn, suffix);
250
- } else {
251
- var promisified = promisifier(fn, function() {
252
- return makeNodePromisified(key, THIS, key, fn, suffix);
253
- });
254
- util.notEnumerableProp(promisified, "__isPromisified__", true);
255
- obj[promisifiedKey] = promisified;
256
- }
257
- }
258
- util.toFastProperties(obj);
259
- return obj;
260
- }
261
-
262
- function promisify(callback, receiver) {
263
- return makeNodePromisified(callback, receiver, undefined, callback);
264
- }
265
-
266
- Promise.promisify = function (fn, receiver) {
267
- if (typeof fn !== "function") {
268
- throw new TypeError("fn must be a function\u000a\u000a See http://goo.gl/916lJJ\u000a");
269
- }
270
- if (isPromisified(fn)) {
271
- return fn;
272
- }
273
- var ret = promisify(fn, arguments.length < 2 ? THIS : receiver);
274
- util.copyDescriptors(fn, ret, propsFilter);
275
- return ret;
276
- };
277
-
278
- Promise.promisifyAll = function (target, options) {
279
- if (typeof target !== "function" && typeof target !== "object") {
280
- throw new TypeError("the target of promisifyAll must be an object or a function\u000a\u000a See http://goo.gl/9ITlV0\u000a");
281
- }
282
- options = Object(options);
283
- var suffix = options.suffix;
284
- if (typeof suffix !== "string") suffix = defaultSuffix;
285
- var filter = options.filter;
286
- if (typeof filter !== "function") filter = defaultFilter;
287
- var promisifier = options.promisifier;
288
- if (typeof promisifier !== "function") promisifier = makeNodePromisified;
289
-
290
- if (!util.isIdentifier(suffix)) {
291
- throw new RangeError("suffix must be a valid identifier\u000a\u000a See http://goo.gl/8FZo5V\u000a");
292
- }
293
-
294
- var keys = util.inheritedDataKeys(target);
295
- for (var i = 0; i < keys.length; ++i) {
296
- var value = target[keys[i]];
297
- if (keys[i] !== "constructor" &&
298
- util.isClass(value)) {
299
- promisifyAll(value.prototype, suffix, filter, promisifier);
300
- promisifyAll(value, suffix, filter, promisifier);
301
- }
302
- }
303
-
304
- return promisifyAll(target, suffix, filter, promisifier);
305
- };
306
- };
307
-