Skip to content

Commit

Permalink
Allow Infinity timeout
Browse files Browse the repository at this point in the history
Could be useful if the user doesn’t want a timeout based on a conditional.
  • Loading branch information
sindresorhus committed May 14, 2017
1 parent e6bed58 commit 7d46b45
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions index.js
Expand Up @@ -8,8 +8,8 @@ class TimeoutError extends Error {
}

module.exports = (promise, ms, fallback) => new Promise((resolve, reject) => {
if (!Number.isFinite(ms)) {
throw new TypeError('Expected `ms` to be a finite number');
if (typeof ms !== 'number') {
throw new TypeError('Expected `ms` to be a number');
}

const timer = setTimeout(() => {
Expand Down

0 comments on commit 7d46b45

Please sign in to comment.