Allow `Infinity` timeout

Could be useful if the user doesn’t want a timeout based on a conditional.
This commit is contained in:
Sindre Sorhus 2017-05-14 21:58:43 +07:00
parent e6bed583f6
commit 7d46b457c3
1 changed files with 2 additions and 2 deletions

View File

@ -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(() => {