Browse files

ensure every and after receive valid durations

  • Loading branch information...
1 parent e50f99b commit b0213d6262833d61be783bb5dffa47cfbb5a4c6c @marcuswestin committed Jun 11, 2013
Showing with 4 additions and 2 deletions.
  1. +1 −0 after.js
  2. +3 −2 every.js
View
1 after.js
@@ -1,4 +1,5 @@
module.exports = function after(durationInMs, fn) {
+ if (typeof durationInMs != 'number') { throw new Error('after() expects a number') }
return setTimeout(fn, durationInMs)
}
View
5 every.js
@@ -1,8 +1,9 @@
var nextTick = require('./nextTick')
-module.exports = function every(intervalMs, fn) {
+module.exports = function every(intervalInMs, fn) {
+ if (typeof intervalInMs != 'number') { throw new Error('every() expects a number') }
nextTick(function executeAndSchedule() {
- setTimeout(executeAndSchedule, intervalMs)
+ setTimeout(executeAndSchedule, intervalInMs)
fn()
})
}

0 comments on commit b0213d6

Please sign in to comment.