From 9e0aa8e232d4c6011af6bd0a8192de308ba96d77 Mon Sep 17 00:00:00 2001 From: bekzod Date: Mon, 4 Dec 2017 10:41:41 +0500 Subject: [PATCH] remove deprecated `deferOnce`, `defer` and `setTimeout` --- README.md | 8 +++---- lib/index.ts | 24 +------------------ tests/cancel-test.ts | 6 ++--- tests/configurable-timeout-test.ts | 2 +- tests/index.ts | 8 +++---- tests/{set-timeout-test.ts => later-test.ts} | 2 +- ...able-test.ts => schedule-iterable-test.ts} | 2 +- ...fer-once-test.ts => schedule-once-test.ts} | 6 ++--- tests/{defer-test.ts => schedule-test.ts} | 2 +- 9 files changed, 19 insertions(+), 41 deletions(-) rename tests/{set-timeout-test.ts => later-test.ts} (99%) rename tests/{defer-iterable-test.ts => schedule-iterable-test.ts} (97%) rename tests/{defer-once-test.ts => schedule-once-test.ts} (97%) rename tests/{defer-test.ts => schedule-test.ts} (99%) diff --git a/README.md b/README.md index 0510cf86..7e809d53 100644 --- a/README.md +++ b/README.md @@ -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: diff --git a/lib/index.ts b/lib/index.ts index 491c4ddf..1352a002 100644 --- a/lib/index.ts +++ b/lib/index.ts @@ -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. */ @@ -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. */ @@ -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; @@ -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); } diff --git a/tests/cancel-test.ts b/tests/cancel-test.ts index 5755c9e4..4c4bc76b 100644 --- a/tests/cancel-test.ts +++ b/tests/cancel-test.ts @@ -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(); @@ -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(); @@ -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; diff --git a/tests/configurable-timeout-test.ts b/tests/configurable-timeout-test.ts index 452befb4..193d0f0c 100644 --- a/tests/configurable-timeout-test.ts +++ b/tests/configurable-timeout-test.ts @@ -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(); diff --git a/tests/index.ts b/tests/index.ts index c4f1617f..38492bb9 100644 --- a/tests/index.ts +++ b/tests/index.ts @@ -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'; diff --git a/tests/set-timeout-test.ts b/tests/later-test.ts similarity index 99% rename from tests/set-timeout-test.ts rename to tests/later-test.ts index cc42eec1..8e0d04a3 100644 --- a/tests/set-timeout-test.ts +++ b/tests/later-test.ts @@ -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; diff --git a/tests/defer-iterable-test.ts b/tests/schedule-iterable-test.ts similarity index 97% rename from tests/defer-iterable-test.ts rename to tests/schedule-iterable-test.ts index 1735ca7c..05dbd684 100644 --- a/tests/defer-iterable-test.ts +++ b/tests/schedule-iterable-test.ts @@ -1,6 +1,6 @@ import Backburner from 'backburner'; -QUnit.module('tests/defer-iterable'); +QUnit.module('tests/schedule-iterable'); class Iterator { private _collection: Function[]; diff --git a/tests/defer-once-test.ts b/tests/schedule-once-test.ts similarity index 97% rename from tests/defer-once-test.ts rename to tests/schedule-once-test.ts index 53e45048..8afc677a 100644 --- a/tests/defer-once-test.ts +++ b/tests/schedule-once-test.ts @@ -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); @@ -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) { @@ -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) { diff --git a/tests/defer-test.ts b/tests/schedule-test.ts similarity index 99% rename from tests/defer-test.ts rename to tests/schedule-test.ts index 76d9b60d..2daf6314 100644 --- a/tests/defer-test.ts +++ b/tests/schedule-test.ts @@ -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; }