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,168 +0,0 @@
1
- "use strict";
2
- module.exports =
3
- function(Promise, PromiseArray, tryConvertToPromise, INTERNAL, async,
4
- getDomain) {
5
- var util = require("./util");
6
- var canEvaluate = util.canEvaluate;
7
- var tryCatch = util.tryCatch;
8
- var errorObj = util.errorObj;
9
- var reject;
10
-
11
- if (!false) {
12
- if (canEvaluate) {
13
- var thenCallback = function(i) {
14
- return new Function("value", "holder", " \n\
15
- 'use strict'; \n\
16
- holder.pIndex = value; \n\
17
- holder.checkFulfillment(this); \n\
18
- ".replace(/Index/g, i));
19
- };
20
-
21
- var promiseSetter = function(i) {
22
- return new Function("promise", "holder", " \n\
23
- 'use strict'; \n\
24
- holder.pIndex = promise; \n\
25
- ".replace(/Index/g, i));
26
- };
27
-
28
- var generateHolderClass = function(total) {
29
- var props = new Array(total);
30
- for (var i = 0; i < props.length; ++i) {
31
- props[i] = "this.p" + (i+1);
32
- }
33
- var assignment = props.join(" = ") + " = null;";
34
- var cancellationCode= "var promise;\n" + props.map(function(prop) {
35
- return " \n\
36
- promise = " + prop + "; \n\
37
- if (promise instanceof Promise) { \n\
38
- promise.cancel(); \n\
39
- } \n\
40
- ";
41
- }).join("\n");
42
- var passedArguments = props.join(", ");
43
- var name = "Holder$" + total;
44
-
45
-
46
- var code = "return function(tryCatch, errorObj, Promise, async) { \n\
47
- 'use strict'; \n\
48
- function [TheName](fn) { \n\
49
- [TheProperties] \n\
50
- this.fn = fn; \n\
51
- this.asyncNeeded = true; \n\
52
- this.now = 0; \n\
53
- } \n\
54
- \n\
55
- [TheName].prototype._callFunction = function(promise) { \n\
56
- promise._pushContext(); \n\
57
- var ret = tryCatch(this.fn)([ThePassedArguments]); \n\
58
- promise._popContext(); \n\
59
- if (ret === errorObj) { \n\
60
- promise._rejectCallback(ret.e, false); \n\
61
- } else { \n\
62
- promise._resolveCallback(ret); \n\
63
- } \n\
64
- }; \n\
65
- \n\
66
- [TheName].prototype.checkFulfillment = function(promise) { \n\
67
- var now = ++this.now; \n\
68
- if (now === [TheTotal]) { \n\
69
- if (this.asyncNeeded) { \n\
70
- async.invoke(this._callFunction, this, promise); \n\
71
- } else { \n\
72
- this._callFunction(promise); \n\
73
- } \n\
74
- \n\
75
- } \n\
76
- }; \n\
77
- \n\
78
- [TheName].prototype._resultCancelled = function() { \n\
79
- [CancellationCode] \n\
80
- }; \n\
81
- \n\
82
- return [TheName]; \n\
83
- }(tryCatch, errorObj, Promise, async); \n\
84
- ";
85
-
86
- code = code.replace(/\[TheName\]/g, name)
87
- .replace(/\[TheTotal\]/g, total)
88
- .replace(/\[ThePassedArguments\]/g, passedArguments)
89
- .replace(/\[TheProperties\]/g, assignment)
90
- .replace(/\[CancellationCode\]/g, cancellationCode);
91
-
92
- return new Function("tryCatch", "errorObj", "Promise", "async", code)
93
- (tryCatch, errorObj, Promise, async);
94
- };
95
-
96
- var holderClasses = [];
97
- var thenCallbacks = [];
98
- var promiseSetters = [];
99
-
100
- for (var i = 0; i < 8; ++i) {
101
- holderClasses.push(generateHolderClass(i + 1));
102
- thenCallbacks.push(thenCallback(i + 1));
103
- promiseSetters.push(promiseSetter(i + 1));
104
- }
105
-
106
- reject = function (reason) {
107
- this._reject(reason);
108
- };
109
- }}
110
-
111
- Promise.join = function () {
112
- var last = arguments.length - 1;
113
- var fn;
114
- if (last > 0 && typeof arguments[last] === "function") {
115
- fn = arguments[last];
116
- if (!false) {
117
- if (last <= 8 && canEvaluate) {
118
- var ret = new Promise(INTERNAL);
119
- ret._captureStackTrace();
120
- var HolderClass = holderClasses[last - 1];
121
- var holder = new HolderClass(fn);
122
- var callbacks = thenCallbacks;
123
-
124
- for (var i = 0; i < last; ++i) {
125
- var maybePromise = tryConvertToPromise(arguments[i], ret);
126
- if (maybePromise instanceof Promise) {
127
- maybePromise = maybePromise._target();
128
- var bitField = maybePromise._bitField;
129
- ;
130
- if (((bitField & 50397184) === 0)) {
131
- maybePromise._then(callbacks[i], reject,
132
- undefined, ret, holder);
133
- promiseSetters[i](maybePromise, holder);
134
- holder.asyncNeeded = false;
135
- } else if (((bitField & 33554432) !== 0)) {
136
- callbacks[i].call(ret,
137
- maybePromise._value(), holder);
138
- } else if (((bitField & 16777216) !== 0)) {
139
- ret._reject(maybePromise._reason());
140
- } else {
141
- ret._cancel();
142
- }
143
- } else {
144
- callbacks[i].call(ret, maybePromise, holder);
145
- }
146
- }
147
-
148
- if (!ret._isFateSealed()) {
149
- if (holder.asyncNeeded) {
150
- var domain = getDomain();
151
- if (domain !== null) {
152
- holder.fn = util.domainBind(domain, holder.fn);
153
- }
154
- }
155
- ret._setAsyncGuaranteed();
156
- ret._setOnCancel(holder);
157
- }
158
- return ret;
159
- }
160
- }
161
- }
162
- var $_len = arguments.length;var args = new Array($_len); for(var $_i = 0; $_i < $_len; ++$_i) {args[$_i] = arguments[$_i];};
163
- if (fn) args.pop();
164
- var ret = new PromiseArray(args).promise();
165
- return fn !== undefined ? ret.spread(fn) : ret;
166
- };
167
-
168
- };
@@ -1,168 +0,0 @@
1
- "use strict";
2
- module.exports = function(Promise,
3
- PromiseArray,
4
- apiRejection,
5
- tryConvertToPromise,
6
- INTERNAL,
7
- debug) {
8
- var getDomain = Promise._getDomain;
9
- var util = require("./util");
10
- var tryCatch = util.tryCatch;
11
- var errorObj = util.errorObj;
12
- var async = Promise._async;
13
-
14
- function MappingPromiseArray(promises, fn, limit, _filter) {
15
- this.constructor$(promises);
16
- this._promise._captureStackTrace();
17
- var domain = getDomain();
18
- this._callback = domain === null ? fn : util.domainBind(domain, fn);
19
- this._preservedValues = _filter === INTERNAL
20
- ? new Array(this.length())
21
- : null;
22
- this._limit = limit;
23
- this._inFlight = 0;
24
- this._queue = [];
25
- async.invoke(this._asyncInit, this, undefined);
26
- }
27
- util.inherits(MappingPromiseArray, PromiseArray);
28
-
29
- MappingPromiseArray.prototype._asyncInit = function() {
30
- this._init$(undefined, -2);
31
- };
32
-
33
- MappingPromiseArray.prototype._init = function () {};
34
-
35
- MappingPromiseArray.prototype._promiseFulfilled = function (value, index) {
36
- var values = this._values;
37
- var length = this.length();
38
- var preservedValues = this._preservedValues;
39
- var limit = this._limit;
40
-
41
- if (index < 0) {
42
- index = (index * -1) - 1;
43
- values[index] = value;
44
- if (limit >= 1) {
45
- this._inFlight--;
46
- this._drainQueue();
47
- if (this._isResolved()) return true;
48
- }
49
- } else {
50
- if (limit >= 1 && this._inFlight >= limit) {
51
- values[index] = value;
52
- this._queue.push(index);
53
- return false;
54
- }
55
- if (preservedValues !== null) preservedValues[index] = value;
56
-
57
- var promise = this._promise;
58
- var callback = this._callback;
59
- var receiver = promise._boundValue();
60
- promise._pushContext();
61
- var ret = tryCatch(callback).call(receiver, value, index, length);
62
- var promiseCreated = promise._popContext();
63
- debug.checkForgottenReturns(
64
- ret,
65
- promiseCreated,
66
- preservedValues !== null ? "Promise.filter" : "Promise.map",
67
- promise
68
- );
69
- if (ret === errorObj) {
70
- this._reject(ret.e);
71
- return true;
72
- }
73
-
74
- var maybePromise = tryConvertToPromise(ret, this._promise);
75
- if (maybePromise instanceof Promise) {
76
- maybePromise = maybePromise._target();
77
- var bitField = maybePromise._bitField;
78
- ;
79
- if (((bitField & 50397184) === 0)) {
80
- if (limit >= 1) this._inFlight++;
81
- values[index] = maybePromise;
82
- maybePromise._proxy(this, (index + 1) * -1);
83
- return false;
84
- } else if (((bitField & 33554432) !== 0)) {
85
- ret = maybePromise._value();
86
- } else if (((bitField & 16777216) !== 0)) {
87
- this._reject(maybePromise._reason());
88
- return true;
89
- } else {
90
- this._cancel();
91
- return true;
92
- }
93
- }
94
- values[index] = ret;
95
- }
96
- var totalResolved = ++this._totalResolved;
97
- if (totalResolved >= length) {
98
- if (preservedValues !== null) {
99
- this._filter(values, preservedValues);
100
- } else {
101
- this._resolve(values);
102
- }
103
- return true;
104
- }
105
- return false;
106
- };
107
-
108
- MappingPromiseArray.prototype._drainQueue = function () {
109
- var queue = this._queue;
110
- var limit = this._limit;
111
- var values = this._values;
112
- while (queue.length > 0 && this._inFlight < limit) {
113
- if (this._isResolved()) return;
114
- var index = queue.pop();
115
- this._promiseFulfilled(values[index], index);
116
- }
117
- };
118
-
119
- MappingPromiseArray.prototype._filter = function (booleans, values) {
120
- var len = values.length;
121
- var ret = new Array(len);
122
- var j = 0;
123
- for (var i = 0; i < len; ++i) {
124
- if (booleans[i]) ret[j++] = values[i];
125
- }
126
- ret.length = j;
127
- this._resolve(ret);
128
- };
129
-
130
- MappingPromiseArray.prototype.preservedValues = function () {
131
- return this._preservedValues;
132
- };
133
-
134
- function map(promises, fn, options, _filter) {
135
- if (typeof fn !== "function") {
136
- return apiRejection("expecting a function but got " + util.classString(fn));
137
- }
138
-
139
- var limit = 0;
140
- if (options !== undefined) {
141
- if (typeof options === "object" && options !== null) {
142
- if (typeof options.concurrency !== "number") {
143
- return Promise.reject(
144
- new TypeError("'concurrency' must be a number but it is " +
145
- util.classString(options.concurrency)));
146
- }
147
- limit = options.concurrency;
148
- } else {
149
- return Promise.reject(new TypeError(
150
- "options argument must be an object but it is " +
151
- util.classString(options)));
152
- }
153
- }
154
- limit = typeof limit === "number" &&
155
- isFinite(limit) && limit >= 1 ? limit : 0;
156
- return new MappingPromiseArray(promises, fn, limit, _filter).promise();
157
- }
158
-
159
- Promise.prototype.map = function (fn, options) {
160
- return map(this, fn, options, null);
161
- };
162
-
163
- Promise.map = function (promises, fn, options, _filter) {
164
- return map(promises, fn, options, _filter);
165
- };
166
-
167
-
168
- };
@@ -1,55 +0,0 @@
1
- "use strict";
2
- module.exports =
3
- function(Promise, INTERNAL, tryConvertToPromise, apiRejection, debug) {
4
- var util = require("./util");
5
- var tryCatch = util.tryCatch;
6
-
7
- Promise.method = function (fn) {
8
- if (typeof fn !== "function") {
9
- throw new Promise.TypeError("expecting a function but got " + util.classString(fn));
10
- }
11
- return function () {
12
- var ret = new Promise(INTERNAL);
13
- ret._captureStackTrace();
14
- ret._pushContext();
15
- var value = tryCatch(fn).apply(this, arguments);
16
- var promiseCreated = ret._popContext();
17
- debug.checkForgottenReturns(
18
- value, promiseCreated, "Promise.method", ret);
19
- ret._resolveFromSyncValue(value);
20
- return ret;
21
- };
22
- };
23
-
24
- Promise.attempt = Promise["try"] = function (fn) {
25
- if (typeof fn !== "function") {
26
- return apiRejection("expecting a function but got " + util.classString(fn));
27
- }
28
- var ret = new Promise(INTERNAL);
29
- ret._captureStackTrace();
30
- ret._pushContext();
31
- var value;
32
- if (arguments.length > 1) {
33
- debug.deprecated("calling Promise.try with more than 1 argument");
34
- var arg = arguments[1];
35
- var ctx = arguments[2];
36
- value = util.isArray(arg) ? tryCatch(fn).apply(ctx, arg)
37
- : tryCatch(fn).call(ctx, arg);
38
- } else {
39
- value = tryCatch(fn)();
40
- }
41
- var promiseCreated = ret._popContext();
42
- debug.checkForgottenReturns(
43
- value, promiseCreated, "Promise.try", ret);
44
- ret._resolveFromSyncValue(value);
45
- return ret;
46
- };
47
-
48
- Promise.prototype._resolveFromSyncValue = function (value) {
49
- if (value === util.errorObj) {
50
- this._rejectCallback(value.e, false);
51
- } else {
52
- this._resolveCallback(value, true);
53
- }
54
- };
55
- };
@@ -1,51 +0,0 @@
1
- "use strict";
2
- var util = require("./util");
3
- var maybeWrapAsError = util.maybeWrapAsError;
4
- var errors = require("./errors");
5
- var OperationalError = errors.OperationalError;
6
- var es5 = require("./es5");
7
-
8
- function isUntypedError(obj) {
9
- return obj instanceof Error &&
10
- es5.getPrototypeOf(obj) === Error.prototype;
11
- }
12
-
13
- var rErrorKey = /^(?:name|message|stack|cause)$/;
14
- function wrapAsOperationalError(obj) {
15
- var ret;
16
- if (isUntypedError(obj)) {
17
- ret = new OperationalError(obj);
18
- ret.name = obj.name;
19
- ret.message = obj.message;
20
- ret.stack = obj.stack;
21
- var keys = es5.keys(obj);
22
- for (var i = 0; i < keys.length; ++i) {
23
- var key = keys[i];
24
- if (!rErrorKey.test(key)) {
25
- ret[key] = obj[key];
26
- }
27
- }
28
- return ret;
29
- }
30
- util.markAsOriginatingFromRejection(obj);
31
- return obj;
32
- }
33
-
34
- function nodebackForPromise(promise, multiArgs) {
35
- return function(err, value) {
36
- if (promise === null) return;
37
- if (err) {
38
- var wrapped = wrapAsOperationalError(maybeWrapAsError(err));
39
- promise._attachExtraTrace(wrapped);
40
- promise._reject(wrapped);
41
- } else if (!multiArgs) {
42
- promise._fulfill(value);
43
- } else {
44
- var $_len = arguments.length;var args = new Array(Math.max($_len - 1, 0)); for(var $_i = 1; $_i < $_len; ++$_i) {args[$_i - 1] = arguments[$_i];};
45
- promise._fulfill(args);
46
- }
47
- promise = null;
48
- };
49
- }
50
-
51
- module.exports = nodebackForPromise;
@@ -1,58 +0,0 @@
1
- "use strict";
2
- module.exports = function(Promise) {
3
- var util = require("./util");
4
- var async = Promise._async;
5
- var tryCatch = util.tryCatch;
6
- var errorObj = util.errorObj;
7
-
8
- function spreadAdapter(val, nodeback) {
9
- var promise = this;
10
- if (!util.isArray(val)) return successAdapter.call(promise, val, nodeback);
11
- var ret =
12
- tryCatch(nodeback).apply(promise._boundValue(), [null].concat(val));
13
- if (ret === errorObj) {
14
- async.throwLater(ret.e);
15
- }
16
- }
17
-
18
- function successAdapter(val, nodeback) {
19
- var promise = this;
20
- var receiver = promise._boundValue();
21
- var ret = val === undefined
22
- ? tryCatch(nodeback).call(receiver, null)
23
- : tryCatch(nodeback).call(receiver, null, val);
24
- if (ret === errorObj) {
25
- async.throwLater(ret.e);
26
- }
27
- }
28
- function errorAdapter(reason, nodeback) {
29
- var promise = this;
30
- if (!reason) {
31
- var newReason = new Error(reason + "");
32
- newReason.cause = reason;
33
- reason = newReason;
34
- }
35
- var ret = tryCatch(nodeback).call(promise._boundValue(), reason);
36
- if (ret === errorObj) {
37
- async.throwLater(ret.e);
38
- }
39
- }
40
-
41
- Promise.prototype.asCallback = Promise.prototype.nodeify = function (nodeback,
42
- options) {
43
- if (typeof nodeback == "function") {
44
- var adapter = successAdapter;
45
- if (options !== undefined && Object(options).spread) {
46
- adapter = spreadAdapter;
47
- }
48
- this._then(
49
- adapter,
50
- errorAdapter,
51
- undefined,
52
- this,
53
- nodeback
54
- );
55
- }
56
- return this;
57
- };
58
- };