time-queues 1.3.0 → 1.3.1
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 +95 -84
- package/llms-full.txt +430 -0
- package/llms.txt +95 -0
- package/package.json +38 -10
- package/src/CancelTaskError.d.ts +2 -1
- package/src/CancelTaskError.js +0 -2
- package/src/Counter.js +0 -2
- package/src/FrameQueue.d.ts +2 -2
- package/src/FrameQueue.js +0 -2
- package/src/IdleQueue.d.ts +2 -2
- package/src/IdleQueue.js +0 -2
- package/src/LimitedQueue.d.ts +4 -4
- package/src/ListQueue.d.ts +1 -1
- package/src/ListQueue.js +18 -3
- package/src/MicroTask.d.ts +5 -0
- package/src/MicroTask.js +17 -0
- package/src/MicroTaskQueue.d.ts +2 -2
- package/src/MicroTaskQueue.js +17 -3
- package/src/PageWatcher.d.ts +2 -2
- package/src/PageWatcher.js +0 -2
- package/src/Retainer.d.ts +4 -4
- package/src/Retainer.js +0 -2
- package/src/Scheduler.d.ts +5 -4
- package/src/Scheduler.js +1 -2
- package/src/Throttler.d.ts +7 -2
- package/src/Throttler.js +1 -2
- package/src/audit.js +0 -2
- package/src/batch.d.ts +1 -1
- package/src/batch.js +1 -2
- package/src/debounce.js +0 -2
- package/src/defer.d.ts +3 -4
- package/src/defer.js +0 -2
- package/src/index.d.ts +7 -2
- package/src/random-sleep.d.ts +1 -1
- package/src/sample.d.ts +1 -1
- package/src/sample.js +0 -2
- package/src/sleep.js +0 -2
- package/src/throttle.js +0 -2
- package/src/when-dom-loaded.js +0 -2
- package/src/when-loaded.js +0 -2
package/src/audit.js
CHANGED
package/src/batch.d.ts
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
* Runs asynchronous operations in parallel, no more than a specified number at a time.
|
|
3
3
|
* It takes an array of functions, which return promises when invoked without arguments.
|
|
4
4
|
* All other non-function values are passed as-is and promises are resolved.
|
|
5
|
-
*
|
|
5
|
+
* Modeled after Promise.all().
|
|
6
6
|
*
|
|
7
7
|
* @param fns An array of parameterless functions (asynchronous or not), promises, or values
|
|
8
8
|
* @param limit How many asynchronous operations to run in parallel (default is 4)
|
package/src/batch.js
CHANGED
|
@@ -1,7 +1,5 @@
|
|
|
1
1
|
// @ts-self-types="./batch.d.ts"
|
|
2
2
|
|
|
3
|
-
'use strict';
|
|
4
|
-
|
|
5
3
|
const wrap = value => {
|
|
6
4
|
if (typeof value == 'function') return Promise.resolve(value());
|
|
7
5
|
if (value && typeof value.then == 'function') return value; // thenable
|
|
@@ -9,6 +7,7 @@ const wrap = value => {
|
|
|
9
7
|
};
|
|
10
8
|
|
|
11
9
|
export const batch = (fns, limit = 4) => {
|
|
10
|
+
if (!fns.length) return Promise.resolve([]);
|
|
12
11
|
if (limit < 1) limit = 1;
|
|
13
12
|
|
|
14
13
|
const result = [];
|
package/src/debounce.js
CHANGED
package/src/defer.d.ts
CHANGED
|
@@ -6,12 +6,11 @@
|
|
|
6
6
|
* - `setTimeout()`
|
|
7
7
|
*
|
|
8
8
|
* @param fn The function to delay.
|
|
9
|
-
* @returns A function that, when called, will execute the provided function.
|
|
10
9
|
*/
|
|
11
|
-
export declare function defer
|
|
10
|
+
export declare function defer(fn: () => void): void;
|
|
12
11
|
|
|
13
12
|
/**
|
|
14
|
-
* Schedules a function to be called
|
|
13
|
+
* Schedules a function to be called at the next available time.
|
|
15
14
|
*
|
|
16
15
|
* @param fn The function to schedule.
|
|
17
16
|
* @returns A promise that resolves when the function is called.
|
|
@@ -19,7 +18,7 @@ export declare function defer<A extends unknown[]>(fn: (...args: A) => void): (.
|
|
|
19
18
|
export declare function scheduleDefer<R extends unknown>(fn: () => R): Promise<Awaited<R>>;
|
|
20
19
|
|
|
21
20
|
/**
|
|
22
|
-
* Schedules a function to be called
|
|
21
|
+
* Schedules a function to be called at the next available time.
|
|
23
22
|
*
|
|
24
23
|
* @param fn The function to schedule.
|
|
25
24
|
* @returns A promise that resolves when the function is called.
|
package/src/defer.js
CHANGED
package/src/index.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
declare module 'time-queues' {
|
|
2
2
|
export * from './audit';
|
|
3
|
+
export * from './batch';
|
|
3
4
|
export * from './debounce';
|
|
4
5
|
export * from './defer';
|
|
5
6
|
export * from './sample';
|
|
@@ -9,15 +10,19 @@ declare module 'time-queues' {
|
|
|
9
10
|
export * from './CancelTaskError';
|
|
10
11
|
export * from './MicroTask';
|
|
11
12
|
export * from './MicroTaskQueue';
|
|
13
|
+
export * from './LimitedQueue';
|
|
12
14
|
export * from './ListQueue';
|
|
13
15
|
export * from './FrameQueue';
|
|
14
16
|
export * from './IdleQueue';
|
|
15
17
|
|
|
18
|
+
export * from './Counter';
|
|
16
19
|
export * from './PageWatcher';
|
|
17
|
-
export * from './Scheduler';
|
|
18
20
|
export * from './Retainer';
|
|
21
|
+
export * from './Scheduler';
|
|
19
22
|
export * from './Throttler';
|
|
20
|
-
|
|
23
|
+
|
|
24
|
+
export * from './random-dist';
|
|
25
|
+
export * from './random-sleep';
|
|
21
26
|
|
|
22
27
|
export * from './when-dom-loaded';
|
|
23
28
|
export * from './when-loaded';
|
package/src/random-sleep.d.ts
CHANGED
package/src/sample.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Samples a function by ensuring it is not called more often than the specified interval.
|
|
3
3
|
* The last seen arguments are passed to the function after the specified time interval.
|
|
4
|
-
* Unlike `audit()`, intervals are not reset by the function calls and never
|
|
4
|
+
* Unlike `audit()`, intervals are not reset by the function calls and never stop.
|
|
5
5
|
* If no call was made to the sampled function within the specified time interval,
|
|
6
6
|
* no calls are made after the specified time interval.
|
|
7
7
|
*
|
package/src/sample.js
CHANGED
package/src/sleep.js
CHANGED
package/src/throttle.js
CHANGED
package/src/when-dom-loaded.js
CHANGED