Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

remove deprecated deferOnce, defer and setTimeout #290

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,17 +18,17 @@ A priority queue that will efficiently batch, order, reorder and process work; d

`Backburner#run` - execute the passed function and flush any deferred actions

`Backburner#defer` - defer the passed function to run inside the specified queue
`Backburner#schedule` - defer the passed function to run inside the specified queue

`Backburner#deferOnce` - defer the passed function to run inside the specified queue, only execute it once
`Backburner#scheduleOnce` - defer the passed function to run inside the specified queue, only execute it once

`Backburner#setTimeout` - execute the passed function in a specified amount of time
`Backburner#later` - execute the passed function in a specified amount of time

`Backburner#debounce` - execute the passed function in a specified amount of time, reset timer upon additional calls

`Backburner#throttle` - rate-limit the passed function for a specified amount of time

`Backburner#cancel` - cancel a `deferOnce`, `setTimeout`, `debounce` or `throttle`
`Backburner#cancel` - cancel a `scheduleOnce`, `later`, `debounce` or `throttle`

`Backburner#on` - Add an event callback. Supports the following events:

Expand Down
27 changes: 1 addition & 26 deletions lib/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -342,14 +342,6 @@ export default class Backburner {
return this._join(target, method, args);
}

/**
* @deprecated please use schedule instead.
*/
public defer(queueName, target, method, ...args) {
deferCount++;
return this.schedule(queueName, target, method, ...args);
}

/**
* Schedule the passed function to run inside the specified queue.
*/
Expand Down Expand Up @@ -377,14 +369,6 @@ export default class Backburner {
return this._ensureInstance().schedule(queueName, null, iteratorDrain, [iterable], false, stack);
}

/**
* @deprecated please use scheduleOnce instead.
*/
public deferOnce(queueName, target, method, ...args) {
deferOnceCount++;
return this.scheduleOnce(queueName, target, method, ...args);
}

/**
* Schedule the passed function to run once inside the specified queue.
*/
Expand All @@ -398,15 +382,6 @@ export default class Backburner {
return this._ensureInstance().schedule(queueName, target, method, args, true, stack);
}

/**
* @deprecated use later instead.
*/
public setTimeout(...args);
public setTimeout() {
setTimeoutCount++;
return this.later(...arguments);
}

public later<T>(...args: any[]): Timer; // fixes `this.later(...arguments)` usage in `setTimeout`
public later<T>(target: T, methodName: keyof T, wait?: number | string): Timer;
public later<T>(target: T, methodName: keyof T, arg1: any, wait?: number | string): Timer;
Expand Down Expand Up @@ -554,7 +529,7 @@ export default class Backburner {
return this._cancelItem(timer, this._throttlers) || this._cancelItem(timer, this._debouncees);
} else if (timerType === 'string') { // we're cancelling a setTimeout
return this._cancelLaterTimer(timer);
} else if (timerType === 'object' && timer.queue && timer.method) { // we're cancelling a deferOnce
} else if (timerType === 'object' && timer.queue && timer.method) { // we're cancelling a scheduleOnce
return timer.queue.cancel(timer);
}

Expand Down
6 changes: 3 additions & 3 deletions tests/cancel-test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ QUnit.test('scheduleOnce', function(assert) {
});
});

QUnit.test('setTimeout', function(assert) {
QUnit.test('later', function(assert) {
assert.expect(5);
let done = assert.async();

Expand All @@ -43,7 +43,7 @@ QUnit.test('setTimeout', function(assert) {
}, 0);
});

QUnit.test('setTimeout with multiple pending', function(assert) {
QUnit.test('later with multiple pending', function(assert) {
assert.expect(7);

let done = assert.async();
Expand Down Expand Up @@ -73,7 +73,7 @@ QUnit.test('setTimeout with multiple pending', function(assert) {
}, 10);
});

QUnit.test('setTimeout and creating a new later', function(assert) {
QUnit.test('later and creating a new later', function(assert) {
assert.expect(7);
let done = assert.async();
let called = false;
Expand Down
2 changes: 1 addition & 1 deletion tests/configurable-timeout-test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ QUnit.test('We can use a custom setTimeout', function(assert) {
}
});

bb.setTimeout(() => {
bb.later(() => {
assert.ok(customNextWasUsed , 'custom later was used');
done();
});
Expand Down
8 changes: 4 additions & 4 deletions tests/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,14 @@ import './cancel-test';
import './configurable-timeout-test';
import './debounce-test';
import './debug-test';
import './defer-iterable-test';
import './defer-once-test';
import './defer-test';
import './events-test';
import './join-test';
import './later-test';
import './multi-turn-test';
import './queue-push-unique-test';
import './queue-test';
import './run-test';
import './set-timeout-test';
import './schedule-iterable-test';
import './schedule-once-test';
import './schedule-test';
import './throttle-test';
2 changes: 1 addition & 1 deletion tests/set-timeout-test.ts → tests/later-test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import Backburner from 'backburner';
const originalDateNow = Date.now;
const originalDateValueOf = Date.prototype.valueOf;

QUnit.module('tests/set-timeout-test', {
QUnit.module('tests/later', {
afterEach() {
Date.now = originalDateNow;
Date.prototype.valueOf = originalDateValueOf;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import Backburner from 'backburner';

QUnit.module('tests/defer-iterable');
QUnit.module('tests/schedule-iterable');

class Iterator {
private _collection: Function[];
Expand Down
6 changes: 3 additions & 3 deletions tests/defer-once-test.ts → tests/schedule-once-test.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import Backburner from 'backburner';

QUnit.module('tests/defer-once');
QUnit.module('tests/schedule-once');

QUnit.test('when passed a function', function(assert) {
assert.expect(1);
Expand Down Expand Up @@ -76,7 +76,7 @@ QUnit.test('throws when passed an undefined method', function(assert) {
onError
});

bb.run(() => bb.deferOnce('deferErrors', {zomg: 'hi'}, undefined));
bb.run(() => bb.scheduleOnce('deferErrors', {zomg: 'hi'}, undefined));
});

QUnit.test('throws when passed an method name that does not exists on the target', function(assert) {
Expand All @@ -90,7 +90,7 @@ QUnit.test('throws when passed an method name that does not exists on the target
onError
});

bb.run(() => bb.deferOnce('deferErrors', {zomg: 'hi'}, 'checkFunction'));
bb.run(() => bb.scheduleOnce('deferErrors', {zomg: 'hi'}, 'checkFunction'));
});

QUnit.test('when passed a target, method, and arguments', function(assert) {
Expand Down
2 changes: 1 addition & 1 deletion tests/defer-test.ts → tests/schedule-test.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import Backburner from 'backburner';
let originalDateValueOf = Date.prototype.valueOf;

QUnit.module('tests/defer', {
QUnit.module('tests/schedule', {
afterEach() {
Date.prototype.valueOf = originalDateValueOf;
}
Expand Down