timeout-flow 0.0.16 → 0.0.17
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/package.json +1 -1
- package/src/throttle.js +6 -1
- package/types/throttle.d.ts +8 -2
package/package.json
CHANGED
package/src/throttle.js
CHANGED
|
@@ -3,6 +3,11 @@
|
|
|
3
3
|
import { resolveDelayAndFn } from './resolveDelayAndFn.js';
|
|
4
4
|
|
|
5
5
|
|
|
6
|
+
/**
|
|
7
|
+
* @typedef {((...args: any[]) => void) & { cancel: () => void }} ThrottledFunction
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
|
|
6
11
|
/**
|
|
7
12
|
* Creates a throttled version of a function.
|
|
8
13
|
* Executes immediately, throttles further calls, optional trailing execution.
|
|
@@ -10,7 +15,7 @@ import { resolveDelayAndFn } from './resolveDelayAndFn.js';
|
|
|
10
15
|
* @param {Function|string|number} a - Function or delay
|
|
11
16
|
* @param {Function|string|number} b - The other parameter
|
|
12
17
|
* @param {boolean} [trailing=true] - If true, fire once at trailing edge
|
|
13
|
-
|
|
18
|
+
* @returns {ThrottledFunction} Throttled function with a `.cancel()` method
|
|
14
19
|
*/
|
|
15
20
|
export function throttle(a, b, trailing = true) {
|
|
16
21
|
const { fn, delay } = resolveDelayAndFn(a, b);
|
package/types/throttle.d.ts
CHANGED
|
@@ -1,3 +1,6 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @typedef {((...args: any[]) => void) & { cancel: () => void }} ThrottledFunction
|
|
3
|
+
*/
|
|
1
4
|
/**
|
|
2
5
|
* Creates a throttled version of a function.
|
|
3
6
|
* Executes immediately, throttles further calls, optional trailing execution.
|
|
@@ -5,6 +8,9 @@
|
|
|
5
8
|
* @param {Function|string|number} a - Function or delay
|
|
6
9
|
* @param {Function|string|number} b - The other parameter
|
|
7
10
|
* @param {boolean} [trailing=true] - If true, fire once at trailing edge
|
|
8
|
-
|
|
11
|
+
* @returns {ThrottledFunction} Throttled function with a `.cancel()` method
|
|
9
12
|
*/
|
|
10
|
-
export function throttle(a: Function | string | number, b: Function | string | number, trailing?: boolean):
|
|
13
|
+
export function throttle(a: Function | string | number, b: Function | string | number, trailing?: boolean): ThrottledFunction;
|
|
14
|
+
export type ThrottledFunction = ((...args: any[]) => void) & {
|
|
15
|
+
cancel: () => void;
|
|
16
|
+
};
|