timequeue 4.0.2 → 4.0.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.ts +29 -35
- package/dist/index.js +38 -30
- package/dist/index.js.map +1 -1
- package/dist/mem-store.d.ts +2 -2
- package/dist/mem-store.js +0 -1
- package/dist/mem-store.js.map +1 -1
- package/dist/store.d.ts +3 -3
- package/package.json +4 -3
package/dist/index.d.ts
CHANGED
|
@@ -1,54 +1,34 @@
|
|
|
1
1
|
import { EventEmitter } from 'node:events';
|
|
2
|
-
import type
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
export interface Options {
|
|
6
|
-
concurrency?: number;
|
|
7
|
-
every?: number;
|
|
8
|
-
maxQueued?: number;
|
|
9
|
-
timeout?: number;
|
|
10
|
-
store?: Store;
|
|
2
|
+
import type * as store from './store';
|
|
3
|
+
declare class TaskError extends Error {
|
|
4
|
+
args: unknown[];
|
|
11
5
|
}
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
worker: Worker;
|
|
6
|
+
declare class TimeQueue extends EventEmitter {
|
|
7
|
+
static TimeQueue: typeof TimeQueue;
|
|
8
|
+
static default: typeof TimeQueue;
|
|
9
|
+
static TaskError: typeof TaskError;
|
|
10
|
+
worker: TimeQueue.Worker;
|
|
17
11
|
concurrency: number;
|
|
18
12
|
every: number;
|
|
19
13
|
maxQueued: number;
|
|
20
14
|
timeout: number;
|
|
21
15
|
private _isWorkerAsync;
|
|
22
16
|
private _timers;
|
|
23
|
-
|
|
17
|
+
private _generation;
|
|
18
|
+
private _clearing;
|
|
19
|
+
store: TimeQueue.Store;
|
|
24
20
|
active: number;
|
|
25
21
|
intransit: number;
|
|
26
22
|
finished: number;
|
|
27
|
-
|
|
28
|
-
* @constructor
|
|
29
|
-
* @extends {EventEmitter}
|
|
30
|
-
* @param {Function(..., Function(!Error, ...)} worker
|
|
31
|
-
* @param {Object?} options
|
|
32
|
-
* @param {number?} options.concurrency
|
|
33
|
-
* @param {number?} options.every
|
|
34
|
-
* @param {number?} options.maxQueued
|
|
35
|
-
* @param {number?} options.timeout
|
|
36
|
-
*/
|
|
37
|
-
constructor(worker: Worker, options?: Options);
|
|
23
|
+
constructor(worker: TimeQueue.Worker, options?: TimeQueue.Options);
|
|
38
24
|
/**
|
|
39
25
|
* Pushes a task onto the queue.
|
|
40
|
-
*
|
|
41
|
-
* @param {Object} ...args
|
|
42
|
-
* @param {Function(!Error, ...)} callback
|
|
43
|
-
* @return {Promise?}
|
|
44
26
|
*/
|
|
45
|
-
push(...args:
|
|
27
|
+
push(...args: unknown[]): Promise<unknown>;
|
|
46
28
|
/**
|
|
47
29
|
* Starts a task
|
|
48
|
-
*
|
|
49
|
-
* @param {Array.<Object>} args
|
|
50
30
|
*/
|
|
51
|
-
_process(args:
|
|
31
|
+
_process(args: unknown[]): Promise<void>;
|
|
52
32
|
/**
|
|
53
33
|
* Called when a task finishes. Looks at the queue and processes the next
|
|
54
34
|
* waiting task.
|
|
@@ -56,7 +36,21 @@ export default class TimeQueue extends EventEmitter {
|
|
|
56
36
|
_next(): Promise<void>;
|
|
57
37
|
/**
|
|
58
38
|
* Empties the queue and kills the timers.
|
|
59
|
-
* Active tasks will still be completed.
|
|
39
|
+
* Active tasks will still be completed, but no longer update queue state.
|
|
60
40
|
*/
|
|
61
41
|
die(): Promise<void>;
|
|
62
42
|
}
|
|
43
|
+
declare namespace TimeQueue {
|
|
44
|
+
type TaskError = typeof TaskError.prototype;
|
|
45
|
+
type Worker = (...args: any[]) => unknown;
|
|
46
|
+
interface Options {
|
|
47
|
+
concurrency?: number;
|
|
48
|
+
every?: number;
|
|
49
|
+
maxQueued?: number;
|
|
50
|
+
timeout?: number;
|
|
51
|
+
store?: store.Store;
|
|
52
|
+
}
|
|
53
|
+
type Store = store.Store;
|
|
54
|
+
type StoreOptions = store.StoreOptions;
|
|
55
|
+
}
|
|
56
|
+
export = TimeQueue;
|
package/dist/index.js
CHANGED
|
@@ -11,26 +11,15 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
11
11
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
12
12
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
13
13
|
};
|
|
14
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
-
exports.TaskError = void 0;
|
|
16
14
|
const node_events_1 = require("node:events");
|
|
17
15
|
const mem_store_1 = __importDefault(require("./mem-store"));
|
|
18
16
|
class TaskError extends Error {
|
|
19
17
|
}
|
|
20
|
-
exports.TaskError = TaskError;
|
|
21
18
|
class TimeQueue extends node_events_1.EventEmitter {
|
|
22
|
-
/**
|
|
23
|
-
* @constructor
|
|
24
|
-
* @extends {EventEmitter}
|
|
25
|
-
* @param {Function(..., Function(!Error, ...)} worker
|
|
26
|
-
* @param {Object?} options
|
|
27
|
-
* @param {number?} options.concurrency
|
|
28
|
-
* @param {number?} options.every
|
|
29
|
-
* @param {number?} options.maxQueued
|
|
30
|
-
* @param {number?} options.timeout
|
|
31
|
-
*/
|
|
32
19
|
constructor(worker, options = {}) {
|
|
33
20
|
super();
|
|
21
|
+
this._generation = 0;
|
|
22
|
+
this._clearing = null;
|
|
34
23
|
// How many tasks are currently active.
|
|
35
24
|
this.active = 0;
|
|
36
25
|
// How many tasks are still being waited on,
|
|
@@ -50,14 +39,12 @@ class TimeQueue extends node_events_1.EventEmitter {
|
|
|
50
39
|
}
|
|
51
40
|
/**
|
|
52
41
|
* Pushes a task onto the queue.
|
|
53
|
-
*
|
|
54
|
-
* @param {Object} ...args
|
|
55
|
-
* @param {Function(!Error, ...)} callback
|
|
56
|
-
* @return {Promise?}
|
|
57
42
|
*/
|
|
58
|
-
// biome-ignore lint/suspicious/noExplicitAny: tasks accept arbitrary arguments
|
|
59
43
|
push(...args) {
|
|
60
44
|
return __awaiter(this, void 0, void 0, function* () {
|
|
45
|
+
while (this._clearing) {
|
|
46
|
+
yield this._clearing;
|
|
47
|
+
}
|
|
61
48
|
// Returns a promise when no `callback` is given.
|
|
62
49
|
if ((this._isWorkerAsync && args.length === this.worker.length) ||
|
|
63
50
|
(!this._isWorkerAsync && args.length < this.worker.length)) {
|
|
@@ -70,9 +57,7 @@ class TimeQueue extends node_events_1.EventEmitter {
|
|
|
70
57
|
}
|
|
71
58
|
// Calling from the prototype directly fixes an infinute loop bug that
|
|
72
59
|
// occurs when this method is overwritten by a child class.
|
|
73
|
-
TimeQueue.prototype.push.call(this, ...args,
|
|
74
|
-
// biome-ignore lint/suspicious/noExplicitAny: callback can return arbitrary results
|
|
75
|
-
(err, results) => {
|
|
60
|
+
TimeQueue.prototype.push.call(this, ...args, (err, results) => {
|
|
76
61
|
if (err)
|
|
77
62
|
return reject(err);
|
|
78
63
|
resolve(results);
|
|
@@ -94,13 +79,11 @@ class TimeQueue extends node_events_1.EventEmitter {
|
|
|
94
79
|
}
|
|
95
80
|
/**
|
|
96
81
|
* Starts a task
|
|
97
|
-
*
|
|
98
|
-
* @param {Array.<Object>} args
|
|
99
82
|
*/
|
|
100
|
-
// biome-ignore lint/suspicious/noExplicitAny: task args are dynamically typed
|
|
101
83
|
_process(args) {
|
|
102
84
|
return __awaiter(this, void 0, void 0, function* () {
|
|
103
85
|
const callback = args.pop();
|
|
86
|
+
const generation = this._generation;
|
|
104
87
|
let finished = false;
|
|
105
88
|
const every = ~~this.every;
|
|
106
89
|
let tookLongerThanEvery;
|
|
@@ -122,7 +105,6 @@ class TimeQueue extends node_events_1.EventEmitter {
|
|
|
122
105
|
let callbackCalled = false;
|
|
123
106
|
const timeout = ~~this.timeout;
|
|
124
107
|
let tid;
|
|
125
|
-
// biome-ignore lint/suspicious/noExplicitAny: worker result is arbitrary
|
|
126
108
|
const taskCallback = (err, result) => {
|
|
127
109
|
// If this task has timed out, and the callback is called again
|
|
128
110
|
// from the worker, ignore it.
|
|
@@ -137,11 +119,14 @@ class TimeQueue extends node_events_1.EventEmitter {
|
|
|
137
119
|
throw Error('Callback from worker should only be called once');
|
|
138
120
|
}
|
|
139
121
|
callbackCalled = true;
|
|
122
|
+
// `finished` is a lifetime count, so stale tasks still count here.
|
|
140
123
|
this.finished++;
|
|
141
|
-
this.
|
|
124
|
+
const isCurrent = generation === this._generation;
|
|
125
|
+
if (isCurrent)
|
|
126
|
+
this.active--;
|
|
142
127
|
callback(err, result);
|
|
143
128
|
finished = true;
|
|
144
|
-
if (tookLongerThanEvery) {
|
|
129
|
+
if (isCurrent && tookLongerThanEvery) {
|
|
145
130
|
this._next();
|
|
146
131
|
}
|
|
147
132
|
};
|
|
@@ -176,11 +161,16 @@ class TimeQueue extends node_events_1.EventEmitter {
|
|
|
176
161
|
*/
|
|
177
162
|
_next() {
|
|
178
163
|
return __awaiter(this, void 0, void 0, function* () {
|
|
164
|
+
const generation = this._generation;
|
|
179
165
|
if (this.intransit <= this.concurrency) {
|
|
180
166
|
const task = yield this.store.getNextTask();
|
|
167
|
+
if (generation !== this._generation)
|
|
168
|
+
return;
|
|
181
169
|
if (task) {
|
|
182
170
|
this.active++;
|
|
183
171
|
yield this._process(task);
|
|
172
|
+
if (generation !== this._generation)
|
|
173
|
+
return;
|
|
184
174
|
if ((yield this.store.getQueueLen()) === 0) {
|
|
185
175
|
this.emit('empty');
|
|
186
176
|
}
|
|
@@ -194,19 +184,37 @@ class TimeQueue extends node_events_1.EventEmitter {
|
|
|
194
184
|
}
|
|
195
185
|
/**
|
|
196
186
|
* Empties the queue and kills the timers.
|
|
197
|
-
* Active tasks will still be completed.
|
|
187
|
+
* Active tasks will still be completed, but no longer update queue state.
|
|
198
188
|
*/
|
|
199
189
|
die() {
|
|
200
190
|
return __awaiter(this, void 0, void 0, function* () {
|
|
201
|
-
|
|
191
|
+
this._generation++;
|
|
202
192
|
for (const t of this._timers) {
|
|
203
193
|
clearTimeout(t);
|
|
204
194
|
}
|
|
205
195
|
this._timers = [];
|
|
206
196
|
this.intransit = 0;
|
|
207
197
|
this.active = 0;
|
|
198
|
+
const clearing = this.store.clear();
|
|
199
|
+
this._clearing = clearing;
|
|
200
|
+
try {
|
|
201
|
+
yield clearing;
|
|
202
|
+
}
|
|
203
|
+
finally {
|
|
204
|
+
if (this._clearing === clearing) {
|
|
205
|
+
this._clearing = null;
|
|
206
|
+
}
|
|
207
|
+
}
|
|
208
208
|
});
|
|
209
209
|
}
|
|
210
210
|
}
|
|
211
|
-
|
|
211
|
+
TimeQueue.TimeQueue = TimeQueue;
|
|
212
|
+
TimeQueue.default = TimeQueue;
|
|
213
|
+
TimeQueue.TaskError = TaskError;
|
|
214
|
+
// Statically recognizable exports for Node.js cjs-module-lexer (ESM named import support)
|
|
215
|
+
module.exports = TimeQueue;
|
|
216
|
+
module.exports.default = TimeQueue;
|
|
217
|
+
module.exports.TimeQueue = TimeQueue;
|
|
218
|
+
module.exports.TaskError = TaskError;
|
|
219
|
+
module.exports = TimeQueue;
|
|
212
220
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;AAAA,6CAA2C;AAC3C,4DAAsC;AAGtC,MAAM,SAAU,SAAQ,KAAK;CAE5B;AAED,MAAM,SAAU,SAAQ,0BAAY;IA4BlC,YAAY,MAAwB,EAAE,UAA6B,EAAE;QACnE,KAAK,EAAE,CAAC;QAfF,gBAAW,GAAG,CAAC,CAAC;QAChB,cAAS,GAAyB,IAAI,CAAC;QAG/C,uCAAuC;QAChC,WAAM,GAAG,CAAC,CAAC;QAElB,4CAA4C;QAC5C,uCAAuC;QAChC,cAAS,GAAG,CAAC,CAAC;QAErB,gCAAgC;QACzB,aAAQ,GAAG,CAAC,CAAC;QAKlB,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;QACrB,IAAI,CAAC,cAA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
4
|
private _queue;
|
|
5
5
|
constructor(options: StoreOptions);
|
|
6
6
|
getQueueLen(): Promise<number>;
|
|
7
|
-
getNextTask(): Promise<
|
|
8
|
-
pushTask(args:
|
|
7
|
+
getNextTask(): Promise<unknown[]>;
|
|
8
|
+
pushTask(args: unknown[]): Promise<void>;
|
|
9
9
|
clear(): Promise<void>;
|
|
10
10
|
}
|
package/dist/mem-store.js
CHANGED
package/dist/mem-store.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mem-store.js","sourceRoot":"","sources":["../src/mem-store.ts"],"names":[],"mappings":";;;;;;;;;;;AAEA,MAAqB,WAAW;
|
|
1
|
+
{"version":3,"file":"mem-store.js","sourceRoot":"","sources":["../src/mem-store.ts"],"names":[],"mappings":";;;;;;;;;;;AAEA,MAAqB,WAAW;IAG9B,YAAY,OAAqB;QAC/B,IAAI,CAAC,SAAS,GAAG,OAAO,CAAC,SAAS,CAAC;QACnC,IAAI,CAAC,MAAM,GAAG,EAAE,CAAC;IACnB,CAAC;IAEK,WAAW;;YACf,OAAO,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC;QAC5B,CAAC;KAAA;IACK,WAAW;;YACf,OAAO,IAAI,CAAC,MAAM,CAAC,KAAK,EAAE,CAAC;QAC7B,CAAC;KAAA;IACK,QAAQ,CAAC,IAAe;;YAC5B,IAAI,IAAI,CAAC,MAAM,CAAC,MAAM,GAAG,IAAI,CAAC,SAAS,EAAE,CAAC;gBACxC,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;YACzB,CAAC;QACH,CAAC;KAAA;IACK,KAAK;;YACT,IAAI,CAAC,MAAM,GAAG,EAAE,CAAC;QACnB,CAAC;KAAA;CACF;AAtBD,8BAsBC"}
|
package/dist/store.d.ts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
export interface StoreOptions {
|
|
2
|
-
maxQueued
|
|
2
|
+
maxQueued: number;
|
|
3
3
|
}
|
|
4
4
|
export interface Store {
|
|
5
5
|
getQueueLen(): Promise<number>;
|
|
6
|
-
getNextTask(): Promise<
|
|
7
|
-
pushTask(
|
|
6
|
+
getNextTask(): Promise<unknown[] | undefined>;
|
|
7
|
+
pushTask(args: unknown[]): Promise<void>;
|
|
8
8
|
clear(): Promise<void>;
|
|
9
9
|
}
|
package/package.json
CHANGED
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
"flow",
|
|
7
7
|
"time"
|
|
8
8
|
],
|
|
9
|
-
"version": "4.0.
|
|
9
|
+
"version": "4.0.4",
|
|
10
10
|
"repository": {
|
|
11
11
|
"type": "git",
|
|
12
12
|
"url": "git://github.com/fent/timequeue.js.git"
|
|
@@ -21,8 +21,9 @@
|
|
|
21
21
|
"build": "tsc -p tsconfig.build.json",
|
|
22
22
|
"lint": "biome check .",
|
|
23
23
|
"lint:fix": "biome check --write .",
|
|
24
|
-
"test": "nyc --extension .ts --reporter=lcov --reporter=text-summary npm run test:unit",
|
|
25
|
-
"test:unit": "mocha --require ts-node/register test/*-test.ts"
|
|
24
|
+
"test": "nyc --extension .ts --reporter=lcov --reporter=text-summary npm run test:unit && npm run test:package",
|
|
25
|
+
"test:unit": "mocha --require ts-node/register --ignore test/export-test.ts test/*-test.ts",
|
|
26
|
+
"test:package": "mocha --require ts-node/register test/export-test.ts"
|
|
26
27
|
},
|
|
27
28
|
"devDependencies": {
|
|
28
29
|
"@biomejs/biome": "2.5.15",
|