promises: Expose `reject` in `Gate`
parent
b72db7ebd6
commit
a115c475ad
|
@ -56,7 +56,8 @@ exports.timesLimit = async (total, concurrency, promiseCreator) => {
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* An ordinary Promise except the `resolve` executor function is exposed as a property.
|
* An ordinary Promise except the `resolve` and `reject` executor functions are exposed as
|
||||||
|
* properties.
|
||||||
*/
|
*/
|
||||||
class Gate extends Promise {
|
class Gate extends Promise {
|
||||||
// Coax `.then()` into returning an ordinary Promise, not a Gate. See
|
// Coax `.then()` into returning an ordinary Promise, not a Gate. See
|
||||||
|
@ -64,9 +65,9 @@ class Gate extends Promise {
|
||||||
static get [Symbol.species]() { return Promise; }
|
static get [Symbol.species]() { return Promise; }
|
||||||
|
|
||||||
constructor() {
|
constructor() {
|
||||||
let res;
|
let props;
|
||||||
super((resolve, reject) => res = resolve);
|
super((resolve, reject) => props = {resolve, reject});
|
||||||
this.resolve = res;
|
Object.assign(this, props);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
exports.Gate = Gate;
|
exports.Gate = Gate;
|
||||||
|
|
Loading…
Reference in New Issue