time-queues 1.3.1 → 1.3.2
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/README.md +3 -0
- package/llms-full.txt +2 -2
- package/llms.txt +1 -1
- package/package.json +10 -6
- package/src/Counter.d.ts +1 -1
- package/src/FrameQueue.d.ts +3 -3
- package/src/IdleQueue.d.ts +9 -6
- package/src/LimitedQueue.d.ts +3 -3
- package/src/LimitedQueue.js +1 -1
- package/src/ListQueue.d.ts +4 -5
- package/src/MicroTask.d.ts +2 -2
- package/src/MicroTaskQueue.d.ts +3 -3
- package/src/PageWatcher.d.ts +2 -2
- package/src/PageWatcher.js +4 -2
- package/src/Retainer.js +4 -2
- package/src/Scheduler.d.ts +9 -9
- package/src/Scheduler.js +3 -1
- package/src/Throttler.d.ts +1 -5
- package/src/index.d.ts +23 -25
- package/src/random-dist.d.ts +1 -1
- package/src/random-sleep.d.ts +4 -4
package/README.md
CHANGED
|
@@ -140,6 +140,7 @@ BSD-3-Clause
|
|
|
140
140
|
|
|
141
141
|
## Release History
|
|
142
142
|
|
|
143
|
+
- 1.3.2 _Bug fixes (Scheduler, LimitedQueue, PageWatcher, Retainer), corrected `.d.ts` declarations, expanded tests, documentation fixes._
|
|
143
144
|
- 1.3.1 _Fixed `.d.ts` declarations, consolidated TS typing tests, improved documentation._
|
|
144
145
|
- 1.3.0 _Added `batch()`, `LimitedQueue`, random distributions and random sleep functions._
|
|
145
146
|
- 1.2.4 _Updated dependencies._
|
|
@@ -156,3 +157,5 @@ BSD-3-Clause
|
|
|
156
157
|
- 1.0.2 _Updated deps (`list-toolkit`)._
|
|
157
158
|
- 1.0.1 _Minor update in README._
|
|
158
159
|
- 1.0.0 _Initial release._
|
|
160
|
+
|
|
161
|
+
See [release notes](wiki/Release-notes) for more details and history.
|
package/llms-full.txt
CHANGED
|
@@ -205,8 +205,8 @@ class LimitedQueue extends ListQueue {
|
|
|
205
205
|
get activeTasks(): number;
|
|
206
206
|
get isIdle(): boolean;
|
|
207
207
|
waitForIdle(): Promise<void>;
|
|
208
|
-
enqueue(fn: () => unknown): Task;
|
|
209
|
-
schedule(fn: (() => unknown) | null | undefined): Task;
|
|
208
|
+
enqueue(fn: (arg: {task: Task, queue: LimitedQueue}) => unknown): Task;
|
|
209
|
+
schedule(fn: ((arg: {task: Task, queue: LimitedQueue}) => unknown) | null | undefined): Task;
|
|
210
210
|
}
|
|
211
211
|
export { Task };
|
|
212
212
|
export default LimitedQueue;
|
package/llms.txt
CHANGED
|
@@ -54,7 +54,7 @@ const results = await batch(
|
|
|
54
54
|
- **debounce** (`time-queues/debounce.js`) — `debounce(fn, ms): fn`. Delay until input stabilizes.
|
|
55
55
|
- **sample** (`time-queues/sample.js`) — `sample(fn, ms): fn`. Execute at regular intervals with last seen args.
|
|
56
56
|
- **audit** (`time-queues/audit.js`) — `audit(fn, ms): fn`. Collect then execute after delay with last seen args.
|
|
57
|
-
- **batch** (`time-queues/batch.js`) — `batch(fns, limit?): Promise<results[]>`. Run async operations with concurrency limit (default:
|
|
57
|
+
- **batch** (`time-queues/batch.js`) — `batch(fns, limit?): Promise<results[]>`. Run async operations with concurrency limit (default: 4).
|
|
58
58
|
|
|
59
59
|
### Supporting classes
|
|
60
60
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "time-queues",
|
|
3
|
-
"version": "1.3.
|
|
3
|
+
"version": "1.3.2",
|
|
4
4
|
"description": "Lightweight async task scheduling and concurrency control: schedulers, idle/frame/limited queues, throttle, debounce, batch, page lifecycle, random delays. Browsers, Node.js, Deno, Bun.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"types": "./src/index.d.ts",
|
|
@@ -75,7 +75,11 @@
|
|
|
75
75
|
],
|
|
76
76
|
"tape6": {
|
|
77
77
|
"tests": [
|
|
78
|
-
"/tests/test
|
|
78
|
+
"/tests/test-*.js",
|
|
79
|
+
"/tests/test-*.mjs"
|
|
80
|
+
],
|
|
81
|
+
"cli": [
|
|
82
|
+
"/tests/test-*.cjs"
|
|
79
83
|
],
|
|
80
84
|
"importmap": {
|
|
81
85
|
"imports": {
|
|
@@ -86,13 +90,13 @@
|
|
|
86
90
|
}
|
|
87
91
|
},
|
|
88
92
|
"devDependencies": {
|
|
89
|
-
"@types/node": "^25.
|
|
93
|
+
"@types/node": "^25.5.0",
|
|
90
94
|
"prettier": "^3.8.1",
|
|
91
|
-
"tape-six": "^1.7.
|
|
92
|
-
"tape-six-proc": "^1.2.
|
|
95
|
+
"tape-six": "^1.7.12",
|
|
96
|
+
"tape-six-proc": "^1.2.7",
|
|
93
97
|
"typescript": "^5.9.3"
|
|
94
98
|
},
|
|
95
99
|
"dependencies": {
|
|
96
|
-
"list-toolkit": "^2.3.
|
|
100
|
+
"list-toolkit": "^2.3.2"
|
|
97
101
|
}
|
|
98
102
|
}
|
package/src/Counter.d.ts
CHANGED
package/src/FrameQueue.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {ListQueue, Task} from './ListQueue';
|
|
1
|
+
import {ListQueue, Task} from './ListQueue.js';
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
4
|
* A queue based on [requestAnimationFrame()](https://developer.mozilla.org/en-US/docs/Web/API/Window/requestAnimationFrame).
|
|
@@ -33,7 +33,7 @@ export declare class FrameQueue extends ListQueue {
|
|
|
33
33
|
* @param fn The function to execute.
|
|
34
34
|
* @returns The task object.
|
|
35
35
|
*/
|
|
36
|
-
enqueue(fn: ({timeStamp: number
|
|
36
|
+
enqueue(fn: (arg: {timeStamp: number; task: Task; queue: FrameQueue}) => unknown): Task;
|
|
37
37
|
|
|
38
38
|
/**
|
|
39
39
|
* Dequeues a task.
|
|
@@ -48,7 +48,7 @@ export declare class FrameQueue extends ListQueue {
|
|
|
48
48
|
* @returns The task object.
|
|
49
49
|
*/
|
|
50
50
|
schedule(
|
|
51
|
-
fn: (({timeStamp: number
|
|
51
|
+
fn: ((arg: {timeStamp: number; task: Task; queue: FrameQueue}) => unknown) | null | undefined
|
|
52
52
|
): Task;
|
|
53
53
|
|
|
54
54
|
/**
|
package/src/IdleQueue.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {ListQueue, Task} from './ListQueue';
|
|
1
|
+
import {ListQueue, Task} from './ListQueue.js';
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
4
|
* A queue based on [requestIdleCallback()](https://developer.mozilla.org/en-US/docs/Web/API/Window/requestIdleCallback).
|
|
@@ -20,7 +20,7 @@ export declare class IdleQueue extends ListQueue {
|
|
|
20
20
|
/**
|
|
21
21
|
* The options passed to `requestIdleCallback()`.
|
|
22
22
|
*/
|
|
23
|
-
options:
|
|
23
|
+
options: IdleRequestOptions | undefined;
|
|
24
24
|
|
|
25
25
|
/**
|
|
26
26
|
* Creates a new idle queue.
|
|
@@ -28,7 +28,7 @@ export declare class IdleQueue extends ListQueue {
|
|
|
28
28
|
* @param timeoutBatchInMs The timeout batch size in milliseconds.
|
|
29
29
|
* @param options The options passed to `requestIdleCallback()`.
|
|
30
30
|
*/
|
|
31
|
-
constructor(paused?: boolean, timeoutBatchInMs?: number, options?:
|
|
31
|
+
constructor(paused?: boolean, timeoutBatchInMs?: number, options?: IdleRequestOptions);
|
|
32
32
|
|
|
33
33
|
/**
|
|
34
34
|
* Whether the queue is empty.
|
|
@@ -40,7 +40,7 @@ export declare class IdleQueue extends ListQueue {
|
|
|
40
40
|
* @param fn The function to execute.
|
|
41
41
|
* @returns The task object.
|
|
42
42
|
*/
|
|
43
|
-
enqueue(fn: ({deadline: IdleDeadline
|
|
43
|
+
enqueue(fn: (arg: {deadline: IdleDeadline; task: Task; queue: IdleQueue}) => unknown): Task;
|
|
44
44
|
|
|
45
45
|
/**
|
|
46
46
|
* Dequeues a task.
|
|
@@ -55,7 +55,10 @@ export declare class IdleQueue extends ListQueue {
|
|
|
55
55
|
* @returns The task object.
|
|
56
56
|
*/
|
|
57
57
|
schedule(
|
|
58
|
-
fn:
|
|
58
|
+
fn:
|
|
59
|
+
| ((arg: {deadline: IdleDeadline; task: Task; queue: IdleQueue}) => unknown)
|
|
60
|
+
| null
|
|
61
|
+
| undefined
|
|
59
62
|
): Task;
|
|
60
63
|
|
|
61
64
|
/**
|
|
@@ -93,7 +96,7 @@ export const idleQueue: IdleQueue;
|
|
|
93
96
|
* A function that schedules a task to run in the next idle period.
|
|
94
97
|
*/
|
|
95
98
|
export const defer: (
|
|
96
|
-
fn: ({deadline: IdleDeadline
|
|
99
|
+
fn: (arg: {deadline: IdleDeadline; task: Task; queue: IdleQueue}) => unknown
|
|
97
100
|
) => Task;
|
|
98
101
|
|
|
99
102
|
export default idleQueue;
|
package/src/LimitedQueue.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {ListQueue, Task} from './ListQueue';
|
|
1
|
+
import {ListQueue, Task} from './ListQueue.js';
|
|
2
2
|
|
|
3
3
|
export {Task};
|
|
4
4
|
|
|
@@ -58,7 +58,7 @@ export declare class LimitedQueue extends ListQueue {
|
|
|
58
58
|
* @param fn The function to execute when the microtask is scheduled.
|
|
59
59
|
* @returns The enqueued microtask.
|
|
60
60
|
*/
|
|
61
|
-
enqueue(fn: () => unknown): Task;
|
|
61
|
+
enqueue(fn: (arg: {task: Task; queue: LimitedQueue}) => unknown): Task;
|
|
62
62
|
|
|
63
63
|
/**
|
|
64
64
|
* Dequeues a microtask.
|
|
@@ -72,7 +72,7 @@ export declare class LimitedQueue extends ListQueue {
|
|
|
72
72
|
* @param fn The function to execute. If `undefined` or `null`, the task's promise will be resolved with the function's arguments. Otherwise, it is resolved with the function's return value.
|
|
73
73
|
* @returns The task object.
|
|
74
74
|
*/
|
|
75
|
-
schedule(fn: (() => unknown) | null | undefined): Task;
|
|
75
|
+
schedule(fn: ((arg: {task: Task; queue: LimitedQueue}) => unknown) | null | undefined): Task;
|
|
76
76
|
|
|
77
77
|
/**
|
|
78
78
|
* Clears the queue.
|
package/src/LimitedQueue.js
CHANGED
package/src/ListQueue.d.ts
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
|
-
import {MicroTask} from './MicroTask';
|
|
2
|
-
import {MicroTaskQueue} from './MicroTaskQueue';
|
|
3
|
-
import {List} from 'list-toolkit';
|
|
1
|
+
import {MicroTask} from './MicroTask.js';
|
|
2
|
+
import {MicroTaskQueue} from './MicroTaskQueue.js';
|
|
4
3
|
|
|
5
4
|
/**
|
|
6
5
|
* A list-based queue of microtasks that will be executed when scheduled.
|
|
@@ -34,7 +33,7 @@ export declare class ListQueue extends MicroTaskQueue {
|
|
|
34
33
|
* @param fn The function to execute when the microtask is scheduled.
|
|
35
34
|
* @returns The enqueued microtask.
|
|
36
35
|
*/
|
|
37
|
-
enqueue(fn: () => unknown): MicroTask;
|
|
36
|
+
enqueue(fn: (...args: any[]) => unknown): MicroTask;
|
|
38
37
|
|
|
39
38
|
/**
|
|
40
39
|
* Dequeues a microtask.
|
|
@@ -48,7 +47,7 @@ export declare class ListQueue extends MicroTaskQueue {
|
|
|
48
47
|
* @param fn The function to execute. If `undefined` or `null`, the task's promise will be resolved with the function's arguments. Otherwise, it is resolved with the function's return value.
|
|
49
48
|
* @returns The task object.
|
|
50
49
|
*/
|
|
51
|
-
schedule(fn: (() => unknown) | null | undefined): MicroTask;
|
|
50
|
+
schedule(fn: ((...args: any[]) => unknown) | null | undefined): MicroTask;
|
|
52
51
|
|
|
53
52
|
/**
|
|
54
53
|
* Clears the queue.
|
package/src/MicroTask.d.ts
CHANGED
|
@@ -5,7 +5,7 @@ export declare class MicroTask {
|
|
|
5
5
|
/**
|
|
6
6
|
* The function to execute when the microtask is scheduled.
|
|
7
7
|
*/
|
|
8
|
-
fn: () => unknown;
|
|
8
|
+
fn: (...args: any[]) => unknown;
|
|
9
9
|
|
|
10
10
|
/**
|
|
11
11
|
* Whether the microtask has been canceled.
|
|
@@ -16,7 +16,7 @@ export declare class MicroTask {
|
|
|
16
16
|
* Creates a new microtask.
|
|
17
17
|
* @param fn The function to execute when the microtask is scheduled.
|
|
18
18
|
*/
|
|
19
|
-
constructor(fn: () => unknown);
|
|
19
|
+
constructor(fn: (...args: any[]) => unknown);
|
|
20
20
|
|
|
21
21
|
/**
|
|
22
22
|
* Makes a promise that will be resolved when the microtask is executed.
|
package/src/MicroTaskQueue.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import MicroTask from './MicroTask';
|
|
1
|
+
import MicroTask from './MicroTask.js';
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
4
|
* A queue of microtasks that will be executed when scheduled.
|
|
@@ -29,7 +29,7 @@ export declare class MicroTaskQueue {
|
|
|
29
29
|
* @param fn The function to execute when the microtask is scheduled.
|
|
30
30
|
* @returns The enqueued microtask.
|
|
31
31
|
*/
|
|
32
|
-
enqueue(fn: () => unknown): MicroTask;
|
|
32
|
+
enqueue(fn: (...args: any[]) => unknown, ...args: unknown[]): MicroTask;
|
|
33
33
|
|
|
34
34
|
/**
|
|
35
35
|
* Dequeues a microtask from the queue.
|
|
@@ -46,7 +46,7 @@ export declare class MicroTaskQueue {
|
|
|
46
46
|
* @param args Additional arguments to pass to `enqueue()`. They are there to accommodate custom implementations in subclasses.
|
|
47
47
|
* @returns The scheduled microtask.
|
|
48
48
|
*/
|
|
49
|
-
schedule(fn: (() => unknown) | null | undefined, ...args: unknown[]): MicroTask;
|
|
49
|
+
schedule(fn: ((...args: any[]) => unknown) | null | undefined, ...args: unknown[]): MicroTask;
|
|
50
50
|
|
|
51
51
|
/**
|
|
52
52
|
* Clears all tasks from the queue.
|
package/src/PageWatcher.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {ListQueue, Task} from './ListQueue';
|
|
1
|
+
import {ListQueue, Task} from './ListQueue.js';
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
4
|
* A page state.
|
|
@@ -82,7 +82,7 @@ export declare class PageWatcher extends ListQueue {
|
|
|
82
82
|
*/
|
|
83
83
|
export declare const watchStates: (
|
|
84
84
|
queue: ListQueue,
|
|
85
|
-
resumeStatesList
|
|
85
|
+
resumeStatesList?: PageState[]
|
|
86
86
|
) => (state: PageState) => void;
|
|
87
87
|
|
|
88
88
|
/**
|
package/src/PageWatcher.js
CHANGED
|
@@ -27,7 +27,6 @@ export class PageWatcher extends ListQueue {
|
|
|
27
27
|
}
|
|
28
28
|
|
|
29
29
|
pause() {
|
|
30
|
-
this.paused = true;
|
|
31
30
|
watchedEvents.forEach(type => removeEventListener(type, this, eventHandlerOptions));
|
|
32
31
|
return super.pause();
|
|
33
32
|
}
|
|
@@ -50,7 +49,10 @@ export class PageWatcher extends ListQueue {
|
|
|
50
49
|
}
|
|
51
50
|
|
|
52
51
|
clear() {
|
|
53
|
-
this.list.
|
|
52
|
+
while (!this.list.isEmpty) {
|
|
53
|
+
const task = this.list.popFront();
|
|
54
|
+
task.cancel();
|
|
55
|
+
}
|
|
54
56
|
return this;
|
|
55
57
|
}
|
|
56
58
|
|
package/src/Retainer.js
CHANGED
|
@@ -33,11 +33,13 @@ export class Retainer {
|
|
|
33
33
|
await this.destroy(value);
|
|
34
34
|
return this;
|
|
35
35
|
}
|
|
36
|
-
this.handle = setTimeout(
|
|
36
|
+
this.handle = setTimeout(() => {
|
|
37
37
|
const value = this.value;
|
|
38
38
|
this.value = null;
|
|
39
39
|
this.handle = null;
|
|
40
|
-
|
|
40
|
+
Promise.resolve()
|
|
41
|
+
.then(() => this.destroy(value))
|
|
42
|
+
.catch(() => {});
|
|
41
43
|
}, this.retentionPeriod);
|
|
42
44
|
return this;
|
|
43
45
|
}
|
package/src/Scheduler.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import MicroTask from './MicroTask';
|
|
2
|
-
import MicroTaskQueue from './MicroTaskQueue';
|
|
1
|
+
import MicroTask from './MicroTask.js';
|
|
2
|
+
import MicroTaskQueue from './MicroTaskQueue.js';
|
|
3
3
|
|
|
4
4
|
/**
|
|
5
5
|
* A task that will be executed at a later time by `Scheduler`.
|
|
@@ -8,7 +8,7 @@ export declare class Task extends MicroTask {
|
|
|
8
8
|
/**
|
|
9
9
|
* The function to execute.
|
|
10
10
|
*/
|
|
11
|
-
fn: ({task: Task
|
|
11
|
+
fn: (arg: {task: Task; scheduler: Scheduler}) => unknown;
|
|
12
12
|
|
|
13
13
|
/**
|
|
14
14
|
* Whether the task has been canceled.
|
|
@@ -30,7 +30,7 @@ export declare class Task extends MicroTask {
|
|
|
30
30
|
* @param delay The delay before the task is executed. It can be a number of milliseconds or a `Date` object as an absolute time.
|
|
31
31
|
* @param fn The function to execute.
|
|
32
32
|
*/
|
|
33
|
-
constructor(delay: number | Date, fn: ({task: Task
|
|
33
|
+
constructor(delay: number | Date, fn: (arg: {task: Task; scheduler: Scheduler}) => unknown);
|
|
34
34
|
|
|
35
35
|
/**
|
|
36
36
|
* Makes a promise that will be resolved when the microtask is executed.
|
|
@@ -102,14 +102,14 @@ export declare class Scheduler extends MicroTaskQueue {
|
|
|
102
102
|
* @param delay The delay before the task is executed. It can be a number of milliseconds or a `Date` object as an absolute time.
|
|
103
103
|
* @returns The task object that was enqueued.
|
|
104
104
|
*/
|
|
105
|
-
enqueue(fn: ({task: Task
|
|
105
|
+
enqueue(fn: (arg: {task: Task; scheduler: Scheduler}) => unknown, delay: number | Date): Task;
|
|
106
106
|
|
|
107
107
|
/**
|
|
108
108
|
* Removes a task from the scheduler.
|
|
109
109
|
* @param task The task to remove.
|
|
110
110
|
* @returns The scheduler object for chaining.
|
|
111
111
|
*/
|
|
112
|
-
dequeue(task:
|
|
112
|
+
dequeue(task: MicroTask): this;
|
|
113
113
|
|
|
114
114
|
/**
|
|
115
115
|
* Schedules a task to run in the future.
|
|
@@ -118,7 +118,7 @@ export declare class Scheduler extends MicroTaskQueue {
|
|
|
118
118
|
* @returns The task object that was scheduled.
|
|
119
119
|
*/
|
|
120
120
|
schedule(
|
|
121
|
-
fn: (({task: Task
|
|
121
|
+
fn: ((arg: {task: Task; scheduler: Scheduler}) => unknown) | null | undefined,
|
|
122
122
|
delay: number | Date
|
|
123
123
|
): Task;
|
|
124
124
|
|
|
@@ -150,9 +150,9 @@ export declare class Scheduler extends MicroTaskQueue {
|
|
|
150
150
|
* @returns A function that can be used to enqueue the task to the scheduler.
|
|
151
151
|
*/
|
|
152
152
|
export declare const repeat: (
|
|
153
|
-
fn: ({task: Task
|
|
153
|
+
fn: (arg: {task: Task; scheduler: Scheduler}) => void,
|
|
154
154
|
delay: number | Date
|
|
155
|
-
) => ({task: Task
|
|
155
|
+
) => (arg: {task: Task; scheduler: Scheduler}) => void;
|
|
156
156
|
|
|
157
157
|
/**
|
|
158
158
|
* A scheduler instance usually used as a global scheduler.
|
package/src/Scheduler.js
CHANGED
|
@@ -70,6 +70,7 @@ export class Scheduler extends MicroTaskQueue {
|
|
|
70
70
|
dequeue(task) {
|
|
71
71
|
task.cancel();
|
|
72
72
|
if (this.queue.isEmpty) return this;
|
|
73
|
+
if (!this.queue.has(task)) return this;
|
|
73
74
|
if (this.paused || this.queue.top !== task) {
|
|
74
75
|
this.queue.remove(task);
|
|
75
76
|
return this;
|
|
@@ -108,6 +109,7 @@ export class Scheduler extends MicroTaskQueue {
|
|
|
108
109
|
this.queue.top.time <= Date.now() + this.tolerance
|
|
109
110
|
) {
|
|
110
111
|
const task = this.queue.pop();
|
|
112
|
+
if (task.isCanceled) continue;
|
|
111
113
|
task.fn({task, scheduler: this});
|
|
112
114
|
}
|
|
113
115
|
|
|
@@ -118,7 +120,7 @@ export class Scheduler extends MicroTaskQueue {
|
|
|
118
120
|
export const repeat = (fn, delay) => {
|
|
119
121
|
const repeatableFunction = ({task, scheduler}) => {
|
|
120
122
|
fn({task, scheduler});
|
|
121
|
-
scheduler.enqueue(repeatableFunction, isNaN(delay) ? task.delay : delay);
|
|
123
|
+
if (!task.isCanceled) scheduler.enqueue(repeatableFunction, isNaN(delay) ? task.delay : delay);
|
|
122
124
|
};
|
|
123
125
|
return repeatableFunction;
|
|
124
126
|
};
|
package/src/Throttler.d.ts
CHANGED
|
@@ -44,11 +44,7 @@ export declare class Throttler implements ThrottlerOptions {
|
|
|
44
44
|
* Creates a new throttler.
|
|
45
45
|
* @param options The options for the throttler.
|
|
46
46
|
*/
|
|
47
|
-
constructor(
|
|
48
|
-
throttleTimeout = 1_000,
|
|
49
|
-
neverSeenTimeout = 0,
|
|
50
|
-
vacuumPeriod = throttleTimeout * 3
|
|
51
|
-
}: ThrottlerOptions = {});
|
|
47
|
+
constructor(options?: ThrottlerOptions);
|
|
52
48
|
|
|
53
49
|
/**
|
|
54
50
|
* Retrieves the last seen time for a key as a timestamp in milliseconds.
|
package/src/index.d.ts
CHANGED
|
@@ -1,29 +1,27 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
export * from './throttle';
|
|
1
|
+
export * from './audit.js';
|
|
2
|
+
export * from './batch.js';
|
|
3
|
+
export * from './debounce.js';
|
|
4
|
+
export * from './defer.js';
|
|
5
|
+
export * from './sample.js';
|
|
6
|
+
export * from './sleep.js';
|
|
7
|
+
export * from './throttle.js';
|
|
9
8
|
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
9
|
+
export * from './CancelTaskError.js';
|
|
10
|
+
export * from './MicroTask.js';
|
|
11
|
+
export * from './MicroTaskQueue.js';
|
|
12
|
+
export * from './LimitedQueue.js';
|
|
13
|
+
export * from './ListQueue.js';
|
|
14
|
+
export * from './FrameQueue.js';
|
|
15
|
+
export {IdleQueue, idleQueue} from './IdleQueue.js';
|
|
17
16
|
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
17
|
+
export * from './Counter.js';
|
|
18
|
+
export * from './PageWatcher.js';
|
|
19
|
+
export * from './Retainer.js';
|
|
20
|
+
export {Task as SchedulerTask, Scheduler, repeat, scheduler} from './Scheduler.js';
|
|
21
|
+
export * from './Throttler.js';
|
|
23
22
|
|
|
24
|
-
|
|
25
|
-
|
|
23
|
+
export * from './random-dist.js';
|
|
24
|
+
export * from './random-sleep.js';
|
|
26
25
|
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
}
|
|
26
|
+
export * from './when-dom-loaded.js';
|
|
27
|
+
export {whenLoaded, scheduleWhenLoaded} from './when-loaded.js';
|
package/src/random-dist.d.ts
CHANGED
|
@@ -13,7 +13,7 @@ export declare function uniform(min: number, max: number): number;
|
|
|
13
13
|
* @param skewness The skewness of the distribution.
|
|
14
14
|
* @returns A random number from the normal distribution.
|
|
15
15
|
*/
|
|
16
|
-
export declare function normal(mean: number, stdDev: number, skewness
|
|
16
|
+
export declare function normal(mean: number, stdDev: number, skewness?: number): number;
|
|
17
17
|
|
|
18
18
|
/**
|
|
19
19
|
* Generate a random number from an exponential distribution.
|
package/src/random-sleep.d.ts
CHANGED
|
@@ -21,7 +21,7 @@ export declare function randomUniformSleep(min: number, max: number): RandomSlee
|
|
|
21
21
|
export declare function randomNormalSleep(
|
|
22
22
|
mean: number,
|
|
23
23
|
stdDev: number,
|
|
24
|
-
skewness
|
|
24
|
+
skewness?: number
|
|
25
25
|
): RandomSleepFunction;
|
|
26
26
|
|
|
27
27
|
/**
|
|
@@ -34,7 +34,7 @@ export declare function randomNormalSleep(
|
|
|
34
34
|
export declare function randomExpoSleep(
|
|
35
35
|
rate: number,
|
|
36
36
|
range: number,
|
|
37
|
-
base
|
|
37
|
+
base?: number
|
|
38
38
|
): RandomSleepFunction;
|
|
39
39
|
|
|
40
40
|
/**
|
|
@@ -44,7 +44,7 @@ export declare function randomExpoSleep(
|
|
|
44
44
|
* @returns A sleep function.
|
|
45
45
|
* @throws Error if the ratio is not between 0.5 and 1.
|
|
46
46
|
*/
|
|
47
|
-
export declare function randomParetoSleep(min: number, ratio
|
|
47
|
+
export declare function randomParetoSleep(min: number, ratio?: number): RandomSleepFunction;
|
|
48
48
|
|
|
49
49
|
/**
|
|
50
50
|
* A simple sleep function that uses a uniform distribution.
|
|
@@ -52,6 +52,6 @@ export declare function randomParetoSleep(min: number, ratio: number = 0.8): Ran
|
|
|
52
52
|
* @param min The minimum delay in milliseconds.
|
|
53
53
|
* @returns A promise that resolves after the delay.
|
|
54
54
|
*/
|
|
55
|
-
export declare function randomSleep(max: number, min
|
|
55
|
+
export declare function randomSleep(max: number, min?: number): Promise<void>;
|
|
56
56
|
|
|
57
57
|
export default randomSleep;
|