timeout-flow 0.0.15 → 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/debounce.js +2 -2
- package/src/throttle.js +6 -1
- package/types/debounce.d.ts +3 -3
- package/types/throttle.d.ts +8 -2
package/package.json
CHANGED
package/src/debounce.js
CHANGED
|
@@ -12,8 +12,8 @@ import { resolveDelayAndFn } from './resolveDelayAndFn.js';
|
|
|
12
12
|
/**
|
|
13
13
|
* Creates a debounced function that delays invoking `fn` until after `delay` ms.
|
|
14
14
|
*
|
|
15
|
-
* @param {number|Function} a - Delay in ms or the function to debounce.
|
|
16
|
-
* @param {number|Function} [b] - The function to debounce, if delay is first
|
|
15
|
+
* @param {string|number|Function} a - Delay in ms or the function to debounce.
|
|
16
|
+
* @param {string|number|Function} [b] - The function to debounce, if delay is first
|
|
17
17
|
* @returns {DebouncedFunction} A debounced function with `.cancel()`
|
|
18
18
|
*/
|
|
19
19
|
export function debounce(a, b) {
|
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/debounce.d.ts
CHANGED
|
@@ -4,11 +4,11 @@
|
|
|
4
4
|
/**
|
|
5
5
|
* Creates a debounced function that delays invoking `fn` until after `delay` ms.
|
|
6
6
|
*
|
|
7
|
-
* @param {number|Function} a - Delay in ms or the function to debounce.
|
|
8
|
-
* @param {number|Function} [b] - The function to debounce, if delay is first
|
|
7
|
+
* @param {string|number|Function} a - Delay in ms or the function to debounce.
|
|
8
|
+
* @param {string|number|Function} [b] - The function to debounce, if delay is first
|
|
9
9
|
* @returns {DebouncedFunction} A debounced function with `.cancel()`
|
|
10
10
|
*/
|
|
11
|
-
export function debounce(a: number | Function, b?: number | Function): DebouncedFunction;
|
|
11
|
+
export function debounce(a: string | number | Function, b?: string | number | Function): DebouncedFunction;
|
|
12
12
|
export type DebouncedFunction = ((...args: any[]) => void) & {
|
|
13
13
|
cancel: () => void;
|
|
14
14
|
};
|
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
|
+
};
|