Make sure the timeout is positive
This commit is contained in:
parent
fd9ac502ab
commit
33c1e31d79
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 (typeof ms !== 'number') {
|
if (typeof ms !== 'number' && ms >= 0) {
|
||||||
throw new TypeError('Expected `ms` to be a number');
|
throw new TypeError('Expected `ms` to be a positive number');
|
||||||
}
|
}
|
||||||
|
|
||||||
const timer = setTimeout(() => {
|
const timer = setTimeout(() => {
|
||||||
|
|
Loading…
Reference in New Issue