-
Notifications
You must be signed in to change notification settings - Fork 6
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
API parity with clearTimeout/clearInterval and much housekeeping #9
Changes from all commits
82f04f2
7786dd0
07b0a28
dea7e13
c90ff3a
3fe885a
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,3 +4,7 @@ node_js: | |
- '4' | ||
- '6' | ||
- '8' | ||
script: | ||
- npm run cov | ||
after_script: | ||
- codecov |
This file was deleted.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,17 @@ | ||
{ | ||
"name": "safe-timers", | ||
"version": "1.0.1", | ||
"version": "1.1.0", | ||
"description": "Timers with near-infinite duration support", | ||
"main": "index.js", | ||
"files": [ | ||
"index.js" | ||
], | ||
"directories": { | ||
"test": "test" | ||
}, | ||
"scripts": { | ||
"test": "tape test/*.js | tap-spec" | ||
"test": "tape test/*.js | tap-spec", | ||
"cov": "nyc npm test && nyc report --reporter=lcov" | ||
}, | ||
"repository": { | ||
"type": "git", | ||
|
@@ -17,8 +21,10 @@ | |
"setTimeout", | ||
"setInterval", | ||
"timer", | ||
"timeout", | ||
"interval", | ||
"timers", | ||
"timeouts", | ||
"intervals" | ||
], | ||
"author": "Ron Korving <[email protected]>", | ||
|
@@ -28,6 +34,8 @@ | |
}, | ||
"homepage": "https://github.com/Wizcorp/safe-timers#readme", | ||
"devDependencies": { | ||
"codecov": "^3.0.0", | ||
"nyc": "^11.2.1", | ||
"tap-spec": "^4.1.1", | ||
"tape": "^4.5.1" | ||
} | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,64 +4,83 @@ const test = require('tape'); | |
const timers = require('..'); | ||
|
||
test('setTimeoutAt', function (t) { | ||
const originalMaxInterval = timers.maxInterval; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Sorry about this one. Apparently when I copied the raw file contents from PR #1 (and then added to them), I didn't notice it was using spaces instead of tabs. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I noticed last time, but until we add linting rules (I'll do to that later) I wasn't gonna moan about it ;) |
||
|
||
t.test('Crossing the maxInterval border', function (t) { | ||
timers.maxInterval = 2; | ||
|
||
timers.setTimeoutAt(function () { | ||
timers.maxInterval = originalMaxInterval; | ||
|
||
t.pass('timeout fired'); | ||
t.equal(arguments.length, 0); | ||
t.end(); | ||
}, Date.now() + 30); | ||
}); | ||
|
||
t.test('Crossing the maxInterval border with args', function (t) { | ||
timers.maxInterval = 2; | ||
|
||
timers.setTimeoutAt(function (a, b) { | ||
timers.maxInterval = originalMaxInterval; | ||
|
||
t.pass('timeout fired'); | ||
t.equal(arguments.length, 2); | ||
t.equal(a, 1); | ||
t.equal(b, 2); | ||
t.end(); | ||
}, Date.now() + 30, 1, 2); | ||
}); | ||
|
||
t.test('Not crossing the maxInterval border', function (t) { | ||
timers.setTimeoutAt(function () { | ||
t.pass('timeout fired'); | ||
t.equal(arguments.length, 0); | ||
t.end(); | ||
}, Date.now() + 5); | ||
}); | ||
|
||
t.test('Not crossing the maxInterval border with args', function (t) { | ||
timers.setTimeoutAt(function (a, b) { | ||
t.pass('timeout fired'); | ||
t.equal(arguments.length, 2); | ||
t.equal(a, 1); | ||
t.equal(b, 2); | ||
t.end(); | ||
}, Date.now() + 5, 1, 2); | ||
}); | ||
|
||
t.test('clear()', function (t) { | ||
const timeout = timers.setTimeoutAt(function () { | ||
t.end('timeout fired despite clear()'); | ||
}, Date.now() + 0); | ||
|
||
timeout.clear(); | ||
|
||
setTimeout(function () { | ||
t.pass('timeout did not fire'); | ||
t.end(); | ||
}, 10); | ||
}); | ||
|
||
t.end(); | ||
const originalMaxInterval = timers.maxInterval; | ||
|
||
t.test('Crossing the maxInterval border', function (t) { | ||
timers.maxInterval = 2; | ||
|
||
timers.setTimeoutAt(function () { | ||
timers.maxInterval = originalMaxInterval; | ||
|
||
t.pass('timeout fired'); | ||
t.equal(arguments.length, 0); | ||
t.end(); | ||
}, Date.now() + 30); | ||
}); | ||
|
||
t.test('Crossing the maxInterval border with args', function (t) { | ||
timers.maxInterval = 2; | ||
|
||
timers.setTimeoutAt(function (a, b) { | ||
timers.maxInterval = originalMaxInterval; | ||
|
||
t.pass('timeout fired'); | ||
t.equal(arguments.length, 2); | ||
t.equal(a, 1); | ||
t.equal(b, 2); | ||
t.end(); | ||
}, Date.now() + 30, 1, 2); | ||
}); | ||
|
||
t.test('Not crossing the maxInterval border', function (t) { | ||
timers.setTimeoutAt(function () { | ||
t.pass('timeout fired'); | ||
t.equal(arguments.length, 0); | ||
t.end(); | ||
}, Date.now() + 5); | ||
}); | ||
|
||
t.test('Not crossing the maxInterval border with args', function (t) { | ||
timers.setTimeoutAt(function (a, b) { | ||
t.pass('timeout fired'); | ||
t.equal(arguments.length, 2); | ||
t.equal(a, 1); | ||
t.equal(b, 2); | ||
t.end(); | ||
}, Date.now() + 5, 1, 2); | ||
}); | ||
|
||
t.test('clear()', function (t) { | ||
const timeout = timers.setTimeoutAt(function () { | ||
t.end('timeout fired despite clear()'); | ||
}, Date.now() + 0); | ||
|
||
timeout.clear(); | ||
|
||
setTimeout(function () { | ||
t.pass('timeout did not fire'); | ||
t.end(); | ||
}, 10); | ||
}); | ||
|
||
t.test('clearTimeout', function (t) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. And the actual new changes begin here. |
||
const timeout = timers.setTimeoutAt(function () { | ||
t.end('timeout fired despite clearTimeout()'); | ||
}, Date.now() + 0); | ||
|
||
timers.clearTimeout(timeout); | ||
|
||
setTimeout(function () { | ||
t.pass('timeout did not fire'); | ||
t.end(); | ||
}, 10); | ||
}); | ||
|
||
t.test('clearTimeout without timer', function (t) { | ||
timers.clearTimeout(null); | ||
t.pass('no error was thrown'); | ||
t.end(); | ||
}); | ||
|
||
t.end(); | ||
}); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No need to bump version numbers in PRs. That's part of the release process.