mirror of
https://github.com/ether/etherpad-lite.git
synced 2025-01-31 19:02:59 +01:00
promises: Return a Promise
from Gate.then()
It doesn't make sense to return a `Gate` from `Gate.then()`, and this eliminates the semantically confusing constructor parameter.
This commit is contained in:
parent
78a67801f3
commit
b72db7ebd6
1 changed files with 6 additions and 2 deletions
|
@ -59,9 +59,13 @@ exports.timesLimit = async (total, concurrency, promiseCreator) => {
|
|||
* An ordinary Promise except the `resolve` executor function is exposed as a property.
|
||||
*/
|
||||
class Gate extends Promise {
|
||||
constructor(executor = null) {
|
||||
// Coax `.then()` into returning an ordinary Promise, not a Gate. See
|
||||
// https://stackoverflow.com/a/65669070 for the rationale.
|
||||
static get [Symbol.species]() { return Promise; }
|
||||
|
||||
constructor() {
|
||||
let res;
|
||||
super((resolve, reject) => { res = resolve; if (executor != null) executor(resolve, reject); });
|
||||
super((resolve, reject) => res = resolve);
|
||||
this.resolve = res;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue