Allow `Infinity` timeout
Could be useful if the user doesn’t want a timeout based on a conditional.
This commit is contained in:
parent
e6bed583f6
commit
7d46b457c3
4
index.js
4
index.js
|
@ -8,8 +8,8 @@ class TimeoutError extends Error {
|
||||||
}
|
}
|
||||||
|
|
||||||
module.exports = (promise, ms, fallback) => new Promise((resolve, reject) => {
|
module.exports = (promise, ms, fallback) => new Promise((resolve, reject) => {
|
||||||
if (!Number.isFinite(ms)) {
|
if (typeof ms !== 'number') {
|
||||||
throw new TypeError('Expected `ms` to be a finite number');
|
throw new TypeError('Expected `ms` to be a number');
|
||||||
}
|
}
|
||||||
|
|
||||||
const timer = setTimeout(() => {
|
const timer = setTimeout(() => {
|
||||||
|
|
Loading…
Reference in New Issue