summaryrefslogtreecommitdiff
path: root/deps/npm/node_modules/npm-profile/node_modules/make-fetch-happen/node_modules/http-proxy-agent/node_modules/agent-base/node_modules/es6-promisify/node_modules/es6-promise/lib/es6-promise/enumerator.js
diff options
context:
space:
mode:
Diffstat (limited to 'deps/npm/node_modules/npm-profile/node_modules/make-fetch-happen/node_modules/http-proxy-agent/node_modules/agent-base/node_modules/es6-promisify/node_modules/es6-promise/lib/es6-promise/enumerator.js')
-rw-r--r--deps/npm/node_modules/npm-profile/node_modules/make-fetch-happen/node_modules/http-proxy-agent/node_modules/agent-base/node_modules/es6-promisify/node_modules/es6-promise/lib/es6-promise/enumerator.js130
1 files changed, 66 insertions, 64 deletions
diff --git a/deps/npm/node_modules/npm-profile/node_modules/make-fetch-happen/node_modules/http-proxy-agent/node_modules/agent-base/node_modules/es6-promisify/node_modules/es6-promise/lib/es6-promise/enumerator.js b/deps/npm/node_modules/npm-profile/node_modules/make-fetch-happen/node_modules/http-proxy-agent/node_modules/agent-base/node_modules/es6-promisify/node_modules/es6-promise/lib/es6-promise/enumerator.js
index df4faca879..b0eaa9300e 100644
--- a/deps/npm/node_modules/npm-profile/node_modules/make-fetch-happen/node_modules/http-proxy-agent/node_modules/agent-base/node_modules/es6-promisify/node_modules/es6-promise/lib/es6-promise/enumerator.js
+++ b/deps/npm/node_modules/npm-profile/node_modules/make-fetch-happen/node_modules/http-proxy-agent/node_modules/agent-base/node_modules/es6-promisify/node_modules/es6-promise/lib/es6-promise/enumerator.js
@@ -2,7 +2,6 @@ import {
isArray,
isMaybeThenable
} from './utils';
-
import {
noop,
reject,
@@ -21,91 +20,94 @@ import originalResolve from './promise/resolve';
import originalThen from './then';
import { makePromise, PROMISE_ID } from './-internal';
-export default Enumerator;
-function Enumerator(Constructor, input) {
- this._instanceConstructor = Constructor;
- this.promise = new Constructor(noop);
+function validationError() {
+ return new Error('Array Methods must be provided an Array');
+};
- if (!this.promise[PROMISE_ID]) {
- makePromise(this.promise);
- }
+export default class Enumerator {
+ constructor(Constructor, input) {
+ this._instanceConstructor = Constructor;
+ this.promise = new Constructor(noop);
- if (isArray(input)) {
- this.length = input.length;
- this._remaining = input.length;
+ if (!this.promise[PROMISE_ID]) {
+ makePromise(this.promise);
+ }
- this._result = new Array(this.length);
+ if (isArray(input)) {
+ this.length = input.length;
+ this._remaining = input.length;
- if (this.length === 0) {
- fulfill(this.promise, this._result);
- } else {
- this.length = this.length || 0;
- this._enumerate(input);
- if (this._remaining === 0) {
+ this._result = new Array(this.length);
+
+ if (this.length === 0) {
fulfill(this.promise, this._result);
+ } else {
+ this.length = this.length || 0;
+ this._enumerate(input);
+ if (this._remaining === 0) {
+ fulfill(this.promise, this._result);
+ }
}
+ } else {
+ reject(this.promise, validationError());
}
- } else {
- reject(this.promise, validationError());
}
-}
-
-function validationError() {
- return new Error('Array Methods must be provided an Array');
-};
-
-Enumerator.prototype._enumerate = function(input) {
- for (let i = 0; this._state === PENDING && i < input.length; i++) {
- this._eachEntry(input[i], i);
+ _enumerate(input) {
+ for (let i = 0; this._state === PENDING && i < input.length; i++) {
+ this._eachEntry(input[i], i);
+ }
}
-};
-Enumerator.prototype._eachEntry = function(entry, i) {
- let c = this._instanceConstructor;
- let { resolve } = c;
+ _eachEntry(entry, i) {
+ let c = this._instanceConstructor;
+ let { resolve } = c;
- if (resolve === originalResolve) {
- let then = getThen(entry);
+ if (resolve === originalResolve) {
+ let then = getThen(entry);
- if (then === originalThen &&
+ if (then === originalThen &&
entry._state !== PENDING) {
- this._settledAt(entry._state, i, entry._result);
- } else if (typeof then !== 'function') {
- this._remaining--;
- this._result[i] = entry;
- } else if (c === Promise) {
- let promise = new c(noop);
- handleMaybeThenable(promise, entry, then);
- this._willSettleAt(promise, i);
+ this._settledAt(entry._state, i, entry._result);
+ } else if (typeof then !== 'function') {
+ this._remaining--;
+ this._result[i] = entry;
+ } else if (c === Promise) {
+ let promise = new c(noop);
+ handleMaybeThenable(promise, entry, then);
+ this._willSettleAt(promise, i);
+ } else {
+ this._willSettleAt(new c(resolve => resolve(entry)), i);
+ }
} else {
- this._willSettleAt(new c(resolve => resolve(entry)), i);
+ this._willSettleAt(resolve(entry), i);
}
- } else {
- this._willSettleAt(resolve(entry), i);
}
-};
-Enumerator.prototype._settledAt = function(state, i, value) {
- let { promise } = this;
+ _settledAt(state, i, value) {
+ let { promise } = this;
- if (promise._state === PENDING) {
- this._remaining--;
+ if (promise._state === PENDING) {
+ this._remaining--;
- if (state === REJECTED) {
- reject(promise, value);
- } else {
- this._result[i] = value;
+ if (state === REJECTED) {
+ reject(promise, value);
+ } else {
+ this._result[i] = value;
+ }
}
- }
- if (this._remaining === 0) {
- fulfill(promise, this._result);
+ if (this._remaining === 0) {
+ fulfill(promise, this._result);
+ }
}
-};
-Enumerator.prototype._willSettleAt = function(promise, i) {
- let enumerator = this;
+ _willSettleAt(promise, i) {
+ let enumerator = this;
- subscribe(promise, undefined, value => enumerator._settledAt(FULFILLED, i, value),
- reason => enumerator._settledAt(REJECTED, i, reason));
+ subscribe(
+ promise, undefined,
+ value => enumerator._settledAt(FULFILLED, i, value),
+ reason => enumerator._settledAt(REJECTED, i, reason)
+ );
+ }
};