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