Remove unused promise utils method

Signed-off-by: Michael Telatynski <7t3chguy@gmail.com>
pull/21833/head
Michael Telatynski 2019-11-14 00:39:48 +00:00
parent 79ebb9091c
commit bc90789c71
1 changed files with 0 additions and 13 deletions

View File

@ -22,19 +22,6 @@ import Promise from "bluebird";
// Returns a promise which resolves with a given value after the given number of ms // Returns a promise which resolves with a given value after the given number of ms
export const sleep = (ms: number, value: any): Promise => new Promise((resolve => { setTimeout(resolve, ms, value); })); export const sleep = (ms: number, value: any): Promise => new Promise((resolve => { setTimeout(resolve, ms, value); }));
// Returns a promise which resolves when the input promise resolves with its value
// or when the timeout of ms is reached with the value of given timeoutValue
export async function timeout(promise: Promise, timeoutValue: any, ms: number): Promise {
const timeoutPromise = new Promise((resolve) => {
const timeoutId = setTimeout(resolve, ms, timeoutValue);
promise.then(() => {
clearTimeout(timeoutId);
});
});
return Promise.race([promise, timeoutPromise]);
}
// Returns a Deferred // Returns a Deferred
export function defer(): {resolve: () => {}, reject: () => {}, promise: Promise} { export function defer(): {resolve: () => {}, reject: () => {}, promise: Promise} {
let resolve; let resolve;