Additional async rewrite

This commit is contained in:
mmorrison 2019-01-12 04:43:36 -06:00
parent efe12a00aa
commit 29ce0b82d0
24 changed files with 654 additions and 470 deletions

20
lib/Promises.js Normal file
View file

@ -0,0 +1,20 @@
class Promises {
static createTimeout(timeoutMs, timeoutMsg) {
let cancel = null;
const wrapped = new Promise((res, rej) => {
const timeout = setTimeout(
() => {
rej(new Error(timeoutMsg + " - Timed out after " + timeoutMs + "ms"));
},
timeoutMs
);
cancel = () => {
clearTimeout(timeout);
};
});
wrapped.cancel = cancel;
return wrapped;
}
}
module.exports = Promises;