Skip to content

Commit

Permalink
should work with undefined time
Browse files Browse the repository at this point in the history
  • Loading branch information
pemrouz committed May 7, 2016
1 parent 2eeb4ff commit 81d9fdb
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
4 changes: 3 additions & 1 deletion index.js
@@ -1,3 +1,5 @@
module.exports = function time(ms, fn) {
return setTimeout(fn, ms)
return arguments.length === 1
? setTimeout(ms)
: setTimeout(fn, ms)
}
9 changes: 9 additions & 0 deletions test.js
Expand Up @@ -10,4 +10,13 @@ describe('time', function() {
time(75, function(){ expect(result).to.be.ok })
time(99, done)
})

it('should work with undefined time', function(done) {
var result = false
, fn = function(){ result = true }

time(fn)
time(5, function(){ expect(result).to.be.ok })
time(10, done)
})
})

0 comments on commit 81d9fdb

Please sign in to comment.