Skip to content

Commit

Permalink
ensure every and after receive valid durations
Browse files Browse the repository at this point in the history
  • Loading branch information
marcuswestin committed Jun 12, 2013
1 parent e50f99b commit b0213d6
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
1 change: 1 addition & 0 deletions 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)
}

5 changes: 3 additions & 2 deletions 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.