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,94 +0,0 @@
1
- "use strict";
2
- module.exports = function(Promise) {
3
- function PromiseInspection(promise) {
4
- if (promise !== undefined) {
5
- promise = promise._target();
6
- this._bitField = promise._bitField;
7
- this._settledValue = promise._settledValue;
8
- }
9
- else {
10
- this._bitField = 0;
11
- this._settledValue = undefined;
12
- }
13
- }
14
-
15
- PromiseInspection.prototype.value = function () {
16
- if (!this.isFulfilled()) {
17
- throw new TypeError("cannot get fulfillment value of a non-fulfilled promise\u000a\u000a See http://goo.gl/hc1DLj\u000a");
18
- }
19
- return this._settledValue;
20
- };
21
-
22
- PromiseInspection.prototype.error =
23
- PromiseInspection.prototype.reason = function () {
24
- if (!this.isRejected()) {
25
- throw new TypeError("cannot get rejection reason of a non-rejected promise\u000a\u000a See http://goo.gl/hPuiwB\u000a");
26
- }
27
- return this._settledValue;
28
- };
29
-
30
- PromiseInspection.prototype.isFulfilled =
31
- Promise.prototype._isFulfilled = function () {
32
- return (this._bitField & 268435456) > 0;
33
- };
34
-
35
- PromiseInspection.prototype.isRejected =
36
- Promise.prototype._isRejected = function () {
37
- return (this._bitField & 134217728) > 0;
38
- };
39
-
40
- PromiseInspection.prototype.isPending =
41
- Promise.prototype._isPending = function () {
42
- return (this._bitField & 402653184) === 0;
43
- };
44
-
45
- PromiseInspection.prototype.isResolved =
46
- Promise.prototype._isResolved = function () {
47
- return (this._bitField & 402653184) > 0;
48
- };
49
-
50
- Promise.prototype.isPending = function() {
51
- return this._target()._isPending();
52
- };
53
-
54
- Promise.prototype.isRejected = function() {
55
- return this._target()._isRejected();
56
- };
57
-
58
- Promise.prototype.isFulfilled = function() {
59
- return this._target()._isFulfilled();
60
- };
61
-
62
- Promise.prototype.isResolved = function() {
63
- return this._target()._isResolved();
64
- };
65
-
66
- Promise.prototype._value = function() {
67
- return this._settledValue;
68
- };
69
-
70
- Promise.prototype._reason = function() {
71
- this._unsetRejectionIsUnhandled();
72
- return this._settledValue;
73
- };
74
-
75
- Promise.prototype.value = function() {
76
- var target = this._target();
77
- if (!target.isFulfilled()) {
78
- throw new TypeError("cannot get fulfillment value of a non-fulfilled promise\u000a\u000a See http://goo.gl/hc1DLj\u000a");
79
- }
80
- return target._settledValue;
81
- };
82
-
83
- Promise.prototype.reason = function() {
84
- var target = this._target();
85
- if (!target.isRejected()) {
86
- throw new TypeError("cannot get rejection reason of a non-rejected promise\u000a\u000a See http://goo.gl/hPuiwB\u000a");
87
- }
88
- target._unsetRejectionIsUnhandled();
89
- return target._settledValue;
90
- };
91
-
92
-
93
- Promise.PromiseInspection = PromiseInspection;
94
- };
@@ -1,84 +0,0 @@
1
- "use strict";
2
- module.exports = function(Promise, INTERNAL) {
3
- var util = require("./util.js");
4
- var errorObj = util.errorObj;
5
- var isObject = util.isObject;
6
-
7
- function tryConvertToPromise(obj, context) {
8
- if (isObject(obj)) {
9
- if (obj instanceof Promise) {
10
- return obj;
11
- }
12
- else if (isAnyBluebirdPromise(obj)) {
13
- var ret = new Promise(INTERNAL);
14
- obj._then(
15
- ret._fulfillUnchecked,
16
- ret._rejectUncheckedCheckError,
17
- ret._progressUnchecked,
18
- ret,
19
- null
20
- );
21
- return ret;
22
- }
23
- var then = util.tryCatch(getThen)(obj);
24
- if (then === errorObj) {
25
- if (context) context._pushContext();
26
- var ret = Promise.reject(then.e);
27
- if (context) context._popContext();
28
- return ret;
29
- } else if (typeof then === "function") {
30
- return doThenable(obj, then, context);
31
- }
32
- }
33
- return obj;
34
- }
35
-
36
- function getThen(obj) {
37
- return obj.then;
38
- }
39
-
40
- var hasProp = {}.hasOwnProperty;
41
- function isAnyBluebirdPromise(obj) {
42
- return hasProp.call(obj, "_promise0");
43
- }
44
-
45
- function doThenable(x, then, context) {
46
- var promise = new Promise(INTERNAL);
47
- var ret = promise;
48
- if (context) context._pushContext();
49
- promise._captureStackTrace();
50
- if (context) context._popContext();
51
- var synchronous = true;
52
- var result = util.tryCatch(then).call(x,
53
- resolveFromThenable,
54
- rejectFromThenable,
55
- progressFromThenable);
56
- synchronous = false;
57
- if (promise && result === errorObj) {
58
- promise._rejectCallback(result.e, true, true);
59
- promise = null;
60
- }
61
-
62
- function resolveFromThenable(value) {
63
- if (!promise) return;
64
- promise._resolveCallback(value);
65
- promise = null;
66
- }
67
-
68
- function rejectFromThenable(reason) {
69
- if (!promise) return;
70
- promise._rejectCallback(reason, synchronous, true);
71
- promise = null;
72
- }
73
-
74
- function progressFromThenable(value) {
75
- if (!promise) return;
76
- if (typeof promise._progress === "function") {
77
- promise._progress(value);
78
- }
79
- }
80
- return ret;
81
- }
82
-
83
- return tryConvertToPromise;
84
- };
@@ -1,64 +0,0 @@
1
- "use strict";
2
- module.exports = function(Promise, INTERNAL) {
3
- var util = require("./util.js");
4
- var TimeoutError = Promise.TimeoutError;
5
-
6
- var afterTimeout = function (promise, message) {
7
- if (!promise.isPending()) return;
8
-
9
- var err;
10
- if(!util.isPrimitive(message) && (message instanceof Error)) {
11
- err = message;
12
- } else {
13
- if (typeof message !== "string") {
14
- message = "operation timed out";
15
- }
16
- err = new TimeoutError(message);
17
- }
18
- util.markAsOriginatingFromRejection(err);
19
- promise._attachExtraTrace(err);
20
- promise._cancel(err);
21
- };
22
-
23
- var afterValue = function(value) { return delay(+this).thenReturn(value); };
24
- var delay = Promise.delay = function (value, ms) {
25
- if (ms === undefined) {
26
- ms = value;
27
- value = undefined;
28
- var ret = new Promise(INTERNAL);
29
- setTimeout(function() { ret._fulfill(); }, ms);
30
- return ret;
31
- }
32
- ms = +ms;
33
- return Promise.resolve(value)._then(afterValue, null, null, ms, undefined);
34
- };
35
-
36
- Promise.prototype.delay = function (ms) {
37
- return delay(this, ms);
38
- };
39
-
40
- function successClear(value) {
41
- var handle = this;
42
- if (handle instanceof Number) handle = +handle;
43
- clearTimeout(handle);
44
- return value;
45
- }
46
-
47
- function failureClear(reason) {
48
- var handle = this;
49
- if (handle instanceof Number) handle = +handle;
50
- clearTimeout(handle);
51
- throw reason;
52
- }
53
-
54
- Promise.prototype.timeout = function (ms, message) {
55
- ms = +ms;
56
- var ret = this.then().cancellable();
57
- ret._cancellationParent = this;
58
- var handle = setTimeout(function timeoutTimeout() {
59
- afterTimeout(ret, message);
60
- }, ms);
61
- return ret._then(successClear, failureClear, undefined, handle, undefined);
62
- };
63
-
64
- };
@@ -1,213 +0,0 @@
1
- "use strict";
2
- module.exports = function (Promise, apiRejection, tryConvertToPromise,
3
- createContext) {
4
- var TypeError = require("./errors.js").TypeError;
5
- var inherits = require("./util.js").inherits;
6
- var PromiseInspection = Promise.PromiseInspection;
7
-
8
- function inspectionMapper(inspections) {
9
- var len = inspections.length;
10
- for (var i = 0; i < len; ++i) {
11
- var inspection = inspections[i];
12
- if (inspection.isRejected()) {
13
- return Promise.reject(inspection.error());
14
- }
15
- inspections[i] = inspection._settledValue;
16
- }
17
- return inspections;
18
- }
19
-
20
- function thrower(e) {
21
- setTimeout(function(){throw e;}, 0);
22
- }
23
-
24
- function castPreservingDisposable(thenable) {
25
- var maybePromise = tryConvertToPromise(thenable);
26
- if (maybePromise !== thenable &&
27
- typeof thenable._isDisposable === "function" &&
28
- typeof thenable._getDisposer === "function" &&
29
- thenable._isDisposable()) {
30
- maybePromise._setDisposable(thenable._getDisposer());
31
- }
32
- return maybePromise;
33
- }
34
- function dispose(resources, inspection) {
35
- var i = 0;
36
- var len = resources.length;
37
- var ret = Promise.defer();
38
- function iterator() {
39
- if (i >= len) return ret.resolve();
40
- var maybePromise = castPreservingDisposable(resources[i++]);
41
- if (maybePromise instanceof Promise &&
42
- maybePromise._isDisposable()) {
43
- try {
44
- maybePromise = tryConvertToPromise(
45
- maybePromise._getDisposer().tryDispose(inspection),
46
- resources.promise);
47
- } catch (e) {
48
- return thrower(e);
49
- }
50
- if (maybePromise instanceof Promise) {
51
- return maybePromise._then(iterator, thrower,
52
- null, null, null);
53
- }
54
- }
55
- iterator();
56
- }
57
- iterator();
58
- return ret.promise;
59
- }
60
-
61
- function disposerSuccess(value) {
62
- var inspection = new PromiseInspection();
63
- inspection._settledValue = value;
64
- inspection._bitField = 268435456;
65
- return dispose(this, inspection).thenReturn(value);
66
- }
67
-
68
- function disposerFail(reason) {
69
- var inspection = new PromiseInspection();
70
- inspection._settledValue = reason;
71
- inspection._bitField = 134217728;
72
- return dispose(this, inspection).thenThrow(reason);
73
- }
74
-
75
- function Disposer(data, promise, context) {
76
- this._data = data;
77
- this._promise = promise;
78
- this._context = context;
79
- }
80
-
81
- Disposer.prototype.data = function () {
82
- return this._data;
83
- };
84
-
85
- Disposer.prototype.promise = function () {
86
- return this._promise;
87
- };
88
-
89
- Disposer.prototype.resource = function () {
90
- if (this.promise().isFulfilled()) {
91
- return this.promise().value();
92
- }
93
- return null;
94
- };
95
-
96
- Disposer.prototype.tryDispose = function(inspection) {
97
- var resource = this.resource();
98
- var context = this._context;
99
- if (context !== undefined) context._pushContext();
100
- var ret = resource !== null
101
- ? this.doDispose(resource, inspection) : null;
102
- if (context !== undefined) context._popContext();
103
- this._promise._unsetDisposable();
104
- this._data = null;
105
- return ret;
106
- };
107
-
108
- Disposer.isDisposer = function (d) {
109
- return (d != null &&
110
- typeof d.resource === "function" &&
111
- typeof d.tryDispose === "function");
112
- };
113
-
114
- function FunctionDisposer(fn, promise, context) {
115
- this.constructor$(fn, promise, context);
116
- }
117
- inherits(FunctionDisposer, Disposer);
118
-
119
- FunctionDisposer.prototype.doDispose = function (resource, inspection) {
120
- var fn = this.data();
121
- return fn.call(resource, resource, inspection);
122
- };
123
-
124
- function maybeUnwrapDisposer(value) {
125
- if (Disposer.isDisposer(value)) {
126
- this.resources[this.index]._setDisposable(value);
127
- return value.promise();
128
- }
129
- return value;
130
- }
131
-
132
- Promise.using = function () {
133
- var len = arguments.length;
134
- if (len < 2) return apiRejection(
135
- "you must pass at least 2 arguments to Promise.using");
136
- var fn = arguments[len - 1];
137
- if (typeof fn !== "function") return apiRejection("fn must be a function\u000a\u000a See http://goo.gl/916lJJ\u000a");
138
-
139
- var input;
140
- var spreadArgs = true;
141
- if (len === 2 && Array.isArray(arguments[0])) {
142
- input = arguments[0];
143
- len = input.length;
144
- spreadArgs = false;
145
- } else {
146
- input = arguments;
147
- len--;
148
- }
149
- var resources = new Array(len);
150
- for (var i = 0; i < len; ++i) {
151
- var resource = input[i];
152
- if (Disposer.isDisposer(resource)) {
153
- var disposer = resource;
154
- resource = resource.promise();
155
- resource._setDisposable(disposer);
156
- } else {
157
- var maybePromise = tryConvertToPromise(resource);
158
- if (maybePromise instanceof Promise) {
159
- resource =
160
- maybePromise._then(maybeUnwrapDisposer, null, null, {
161
- resources: resources,
162
- index: i
163
- }, undefined);
164
- }
165
- }
166
- resources[i] = resource;
167
- }
168
-
169
- var promise = Promise.settle(resources)
170
- .then(inspectionMapper)
171
- .then(function(vals) {
172
- promise._pushContext();
173
- var ret;
174
- try {
175
- ret = spreadArgs
176
- ? fn.apply(undefined, vals) : fn.call(undefined, vals);
177
- } finally {
178
- promise._popContext();
179
- }
180
- return ret;
181
- })
182
- ._then(
183
- disposerSuccess, disposerFail, undefined, resources, undefined);
184
- resources.promise = promise;
185
- return promise;
186
- };
187
-
188
- Promise.prototype._setDisposable = function (disposer) {
189
- this._bitField = this._bitField | 262144;
190
- this._disposer = disposer;
191
- };
192
-
193
- Promise.prototype._isDisposable = function () {
194
- return (this._bitField & 262144) > 0;
195
- };
196
-
197
- Promise.prototype._getDisposer = function () {
198
- return this._disposer;
199
- };
200
-
201
- Promise.prototype._unsetDisposable = function () {
202
- this._bitField = this._bitField & (~262144);
203
- this._disposer = undefined;
204
- };
205
-
206
- Promise.prototype.disposer = function (fn) {
207
- if (typeof fn === "function") {
208
- return new FunctionDisposer(fn, this, createContext());
209
- }
210
- throw new TypeError();
211
- };
212
-
213
- };