mirror of
https://github.com/ether/etherpad-lite.git
synced 2025-04-23 00:46:16 -04:00
promises: Move Gate from server.js
(to enable reuse)
This commit is contained in:
parent
c8d45586c1
commit
78a67801f3
2 changed files with 13 additions and 8 deletions
|
@ -54,3 +54,15 @@ exports.timesLimit = async (total, concurrency, promiseCreator) => {
|
|||
}
|
||||
await Promise.all(promises);
|
||||
};
|
||||
|
||||
/**
|
||||
* An ordinary Promise except the `resolve` executor function is exposed as a property.
|
||||
*/
|
||||
class Gate extends Promise {
|
||||
constructor(executor = null) {
|
||||
let res;
|
||||
super((resolve, reject) => { res = resolve; if (executor != null) executor(resolve, reject); });
|
||||
this.resolve = res;
|
||||
}
|
||||
}
|
||||
exports.Gate = Gate;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue