appolo-utils
Advanced tools
Comparing version 0.0.47 to 0.0.48
@@ -166,2 +166,11 @@ "use strict"; | ||
} | ||
static promiseTimeout(promise, timeout) { | ||
return new Promise((resolve, reject) => { | ||
let interval = setTimeout(() => reject(new Error("promise timeout")), timeout); | ||
promise | ||
.then(resolve) | ||
.catch(reject) | ||
.finally(() => clearTimeout(interval)); | ||
}); | ||
} | ||
} | ||
@@ -168,0 +177,0 @@ exports.Promises = Promises; |
@@ -227,2 +227,12 @@ type Resolvable<R> = R | PromiseLike<R> | ||
} | ||
public static promiseTimeout<T>(promise: Promise<T>, timeout: number): Promise<T> { | ||
return new Promise<T>((resolve, reject) => { | ||
let interval = setTimeout(() => reject(new Error("promise timeout")), timeout); | ||
promise | ||
.then(resolve) | ||
.catch(reject) | ||
.finally(() => clearTimeout(interval)) | ||
}) | ||
} | ||
} | ||
@@ -229,0 +239,0 @@ |
@@ -17,3 +17,3 @@ { | ||
"main": "./index.js", | ||
"version": "0.0.47", | ||
"version": "0.0.48", | ||
"license": "MIT", | ||
@@ -20,0 +20,0 @@ "repository": { |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
104629
1889