Skip to content

Commit b0aff6e

Browse files
authored
Merge branch 'master' into add-counters
2 parents 8d15b4e + 49eb179 commit b0aff6e

File tree

5 files changed

+600
-83
lines changed

5 files changed

+600
-83
lines changed

ember-cli-build.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ module.exports = function (app) {
7878
}]
7979
}
8080
}),
81-
new Funnel(path.dirname(require.resolve('qunitjs')), {
81+
new Funnel(path.dirname(require.resolve('qunit')), {
8282
annotation: 'tests/qunit.{js,css}',
8383
destDir: 'tests',
8484
files: ['qunit.css', 'qunit.js']

lib/index.ts

+24-28
Original file line numberDiff line numberDiff line change
@@ -158,9 +158,7 @@ export default class Backburner {
158158

159159
this._platform = platform;
160160

161-
this._boundRunExpiredTimers = () => {
162-
this._runExpiredTimers();
163-
};
161+
this._boundRunExpiredTimers = this._runExpiredTimers.bind(this);
164162

165163
this._boundAutorunEnd = () => {
166164
autorunsCompletedCount++;
@@ -586,9 +584,10 @@ export default class Backburner {
586584

587585
public cancel(timer?) {
588586
cancelCount++;
589-
if (!timer) { return false; }
587+
588+
if (timer === undefined || timer === null) { return false; }
589+
590590
let timerType = typeof timer;
591-
592591
if (timerType === 'number') { // we're cancelling a throttle or debounce
593592
return this._cancelItem(timer, this._throttlers) || this._cancelItem(timer, this._debouncees);
594593
} else if (timerType === 'string') { // we're cancelling a setTimeout
@@ -653,18 +652,16 @@ export default class Backburner {
653652
if (this._timers.length === 0) {
654653
this._timers.push(executeAt, id, target, method, args, stack);
655654
this._installTimerTimeout();
656-
return id;
657-
}
658-
659-
// find position to insert
660-
let i = searchTimer(executeAt, this._timers);
661-
this._timers.splice(i, 0, executeAt, id, target, method, args, stack);
655+
} else {
656+
// find position to insert
657+
let i = searchTimer(executeAt, this._timers);
658+
this._timers.splice(i, 0, executeAt, id, target, method, args, stack);
662659

663-
// we should be the new earliest timer if i == 0
664-
if (i === 0) {
665-
this._reinstallTimerTimeout();
660+
// we should be the new earliest timer if i == 0
661+
if (i === 0) {
662+
this._reinstallTimerTimeout();
663+
}
666664
}
667-
668665
return id;
669666
}
670667

@@ -716,10 +713,11 @@ export default class Backburner {
716713

717714
private _runExpiredTimers() {
718715
this._timerTimeoutId = null;
719-
if (this._timers.length === 0) { return; }
720-
this.begin();
721-
this._scheduleExpiredTimers();
722-
this.end();
716+
if (this._timers.length > 0) {
717+
this.begin();
718+
this._scheduleExpiredTimers();
719+
this.end();
720+
}
723721
}
724722

725723
private _scheduleExpiredTimers() {
@@ -731,15 +729,13 @@ export default class Backburner {
731729

732730
for (; i < l; i += 6) {
733731
let executeAt = timers[i];
734-
if (executeAt <= n) {
735-
let target = timers[i + 2];
736-
let method = timers[i + 3];
737-
let args = timers[i + 4];
738-
let stack = timers[i + 5];
739-
this.currentInstance!.schedule(defaultQueue, target, method, args, false, stack);
740-
} else {
741-
break;
742-
}
732+
if (executeAt > n) { break; }
733+
734+
let target = timers[i + 2];
735+
let method = timers[i + 3];
736+
let args = timers[i + 4];
737+
let stack = timers[i + 5];
738+
this.currentInstance!.schedule(defaultQueue, target, method, args, false, stack);
743739
}
744740

745741
timers.splice(0, i);

package.json

+4-4
Original file line numberDiff line numberDiff line change
@@ -27,13 +27,13 @@
2727
"broccoli-merge-trees": "^2.0.0",
2828
"broccoli-rollup": "^2.0.0",
2929
"broccoli-typescript-compiler": "^2.1.1",
30-
"do-you-even-bench": "^1.0.2",
30+
"do-you-even-bench": "^1.0.5",
3131
"ember-cli": "^3.0.0-beta.2",
3232
"ember-cli-dependency-checker": "^2.1.0",
3333
"ember-cli-inject-live-reload": "1.7.0",
34-
"glob": "^7.1.1",
35-
"loader.js": "^4.4.1",
36-
"qunitjs": "^2.4.1",
34+
"glob": "^7.1.2",
35+
"loader.js": "^4.6.0",
36+
"qunit": "^2.5.0",
3737
"rollup-plugin-buble": "^0.18.0",
3838
"tslint": "^5.9.1"
3939
}

tests/debounce-test.ts

-1
Original file line numberDiff line numberDiff line change
@@ -545,7 +545,6 @@ QUnit.test('debounce within a debounce can be canceled GH#183', function(assert)
545545
let done = assert.async();
546546
let bb = new Backburner(['zomg']);
547547

548-
let steps: string[] = [];
549548
let foo = () => {
550549
assert.ok(true, 'foo called');
551550
return bb.debounce(bar, 10);

0 commit comments

Comments
 (0)