Skip to content

Commit

Permalink
remove deprecated deferOnce, defer and setTimeout
Browse files Browse the repository at this point in the history
  • Loading branch information
bekzod committed Jan 20, 2018
1 parent fd24f18 commit 9e0aa8e
Show file tree
Hide file tree
Showing 9 changed files with 19 additions and 41 deletions.
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
24 changes: 1 addition & 23 deletions lib/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -234,13 +234,6 @@ export default class Backburner {
return this._join(target, method, args);
}

/**
* @deprecated please use schedule instead.
*/
public defer(queueName, targetOrMethod, ..._args) {
return this.schedule(queueName, targetOrMethod, ..._args);
}

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

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

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

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

public later(...args) {
let length = args.length;

Expand Down Expand Up @@ -552,7 +530,7 @@ export default class Backburner {
return this._cancelItem(timer, this._throttlers) || this._cancelItem(timer, this._debouncees);
} else if (timerType === 'function') { // 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 @@ -39,7 +39,7 @@ QUnit.test('We can use a custom setTimeout', function(assert) {
}
});

bb.setTimeout(() => {
bb.later(() => {
assert.ok(bb.options._platform.isFakePlatform, 'we are using the fake platform');
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-test', {
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

0 comments on commit 9e0aa8e

Please sign in to comment.