es-toolkit 1.27.0-dev.896 → 1.27.0-dev.898
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/_chunk/{upperFirst-DK_rTF.js → upperFirst-CorAVn.js} +1 -0
- package/dist/browser.global.js +1 -1
- package/dist/browser.global.js.map +1 -1
- package/dist/compat/function/debounce.d.mts +7 -5
- package/dist/compat/function/debounce.d.ts +7 -5
- package/dist/compat/function/throttle.d.mts +3 -4
- package/dist/compat/function/throttle.d.ts +3 -4
- package/dist/compat/function/throttle.mjs +6 -1
- package/dist/compat/index.d.mts +3 -2
- package/dist/compat/index.d.ts +3 -2
- package/dist/compat/index.js +14 -3
- package/dist/compat/index.mjs +1 -1
- package/dist/compat/string/words.d.mts +15 -0
- package/dist/compat/string/words.d.ts +15 -0
- package/dist/compat/string/words.mjs +10 -0
- package/dist/function/debounce.d.mts +24 -22
- package/dist/function/debounce.d.ts +24 -22
- package/dist/function/index.d.mts +2 -2
- package/dist/function/index.d.ts +2 -2
- package/dist/function/throttle.d.mts +7 -5
- package/dist/function/throttle.d.ts +7 -5
- package/dist/index.d.mts +2 -2
- package/dist/index.d.ts +2 -2
- package/dist/index.js +1 -1
- package/dist/string/index.js +1 -1
- package/package.json +1 -1
|
@@ -19,6 +19,11 @@ interface DebounceOptions {
|
|
|
19
19
|
*/
|
|
20
20
|
maxWait?: number;
|
|
21
21
|
}
|
|
22
|
+
interface DebouncedFunction<F extends (...args: any[]) => any> {
|
|
23
|
+
(...args: Parameters<F>): ReturnType<F> | undefined;
|
|
24
|
+
cancel(): void;
|
|
25
|
+
flush(): void;
|
|
26
|
+
}
|
|
22
27
|
/**
|
|
23
28
|
* Creates a debounced function that delays invoking the provided function until after `debounceMs` milliseconds
|
|
24
29
|
* have elapsed since the last time the debounced function was invoked. The debounced function also has a `cancel`
|
|
@@ -65,9 +70,6 @@ interface DebounceOptions {
|
|
|
65
70
|
* // Will cancel the debounced function call
|
|
66
71
|
* controller.abort();
|
|
67
72
|
*/
|
|
68
|
-
declare function debounce<F extends (...args: any[]) => any>(func: F, debounceMs?: number, options?: DebounceOptions):
|
|
69
|
-
cancel: () => void;
|
|
70
|
-
flush: () => void;
|
|
71
|
-
};
|
|
73
|
+
declare function debounce<F extends (...args: any[]) => any>(func: F, debounceMs?: number, options?: DebounceOptions): DebouncedFunction<F>;
|
|
72
74
|
|
|
73
|
-
export { debounce };
|
|
75
|
+
export { type DebouncedFunction, debounce };
|
|
@@ -19,6 +19,11 @@ interface DebounceOptions {
|
|
|
19
19
|
*/
|
|
20
20
|
maxWait?: number;
|
|
21
21
|
}
|
|
22
|
+
interface DebouncedFunction<F extends (...args: any[]) => any> {
|
|
23
|
+
(...args: Parameters<F>): ReturnType<F> | undefined;
|
|
24
|
+
cancel(): void;
|
|
25
|
+
flush(): void;
|
|
26
|
+
}
|
|
22
27
|
/**
|
|
23
28
|
* Creates a debounced function that delays invoking the provided function until after `debounceMs` milliseconds
|
|
24
29
|
* have elapsed since the last time the debounced function was invoked. The debounced function also has a `cancel`
|
|
@@ -65,9 +70,6 @@ interface DebounceOptions {
|
|
|
65
70
|
* // Will cancel the debounced function call
|
|
66
71
|
* controller.abort();
|
|
67
72
|
*/
|
|
68
|
-
declare function debounce<F extends (...args: any[]) => any>(func: F, debounceMs?: number, options?: DebounceOptions):
|
|
69
|
-
cancel: () => void;
|
|
70
|
-
flush: () => void;
|
|
71
|
-
};
|
|
73
|
+
declare function debounce<F extends (...args: any[]) => any>(func: F, debounceMs?: number, options?: DebounceOptions): DebouncedFunction<F>;
|
|
72
74
|
|
|
73
|
-
export { debounce };
|
|
75
|
+
export { type DebouncedFunction, debounce };
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { DebouncedFunction } from './debounce.mjs';
|
|
2
|
+
|
|
1
3
|
interface ThrottleOptions {
|
|
2
4
|
/**
|
|
3
5
|
* An optional AbortSignal to cancel the function invocation on the trailing edge.
|
|
@@ -44,9 +46,6 @@ interface ThrottleOptions {
|
|
|
44
46
|
* throttledFunction(); // Will log 'Function executed'
|
|
45
47
|
* }, 1000);
|
|
46
48
|
*/
|
|
47
|
-
declare function throttle<F extends (...args: any[]) => any>(func: F, throttleMs?: number, options?: ThrottleOptions):
|
|
48
|
-
cancel: () => void;
|
|
49
|
-
flush: () => void;
|
|
50
|
-
};
|
|
49
|
+
declare function throttle<F extends (...args: any[]) => any>(func: F, throttleMs?: number, options?: ThrottleOptions): DebouncedFunction<F>;
|
|
51
50
|
|
|
52
51
|
export { throttle };
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { DebouncedFunction } from './debounce.js';
|
|
2
|
+
|
|
1
3
|
interface ThrottleOptions {
|
|
2
4
|
/**
|
|
3
5
|
* An optional AbortSignal to cancel the function invocation on the trailing edge.
|
|
@@ -44,9 +46,6 @@ interface ThrottleOptions {
|
|
|
44
46
|
* throttledFunction(); // Will log 'Function executed'
|
|
45
47
|
* }, 1000);
|
|
46
48
|
*/
|
|
47
|
-
declare function throttle<F extends (...args: any[]) => any>(func: F, throttleMs?: number, options?: ThrottleOptions):
|
|
48
|
-
cancel: () => void;
|
|
49
|
-
flush: () => void;
|
|
50
|
-
};
|
|
49
|
+
declare function throttle<F extends (...args: any[]) => any>(func: F, throttleMs?: number, options?: ThrottleOptions): DebouncedFunction<F>;
|
|
51
50
|
|
|
52
51
|
export { throttle };
|
|
@@ -5,7 +5,12 @@ function throttle(func, throttleMs = 0, options = {}) {
|
|
|
5
5
|
options = {};
|
|
6
6
|
}
|
|
7
7
|
const { leading = true, trailing = true, signal } = options;
|
|
8
|
-
return debounce(func, throttleMs, {
|
|
8
|
+
return debounce(func, throttleMs, {
|
|
9
|
+
leading,
|
|
10
|
+
trailing,
|
|
11
|
+
signal,
|
|
12
|
+
maxWait: throttleMs,
|
|
13
|
+
});
|
|
9
14
|
}
|
|
10
15
|
|
|
11
16
|
export { throttle };
|
package/dist/compat/index.d.mts
CHANGED
|
@@ -38,6 +38,7 @@ export { noop } from '../function/noop.mjs';
|
|
|
38
38
|
export { once } from '../function/once.mjs';
|
|
39
39
|
export { partial } from '../function/partial.mjs';
|
|
40
40
|
export { partialRight } from '../function/partialRight.mjs';
|
|
41
|
+
export { ThrottledFunction } from '../function/throttle.mjs';
|
|
41
42
|
export { unary } from '../function/unary.mjs';
|
|
42
43
|
export { mean } from '../math/mean.mjs';
|
|
43
44
|
export { meanBy } from '../math/meanBy.mjs';
|
|
@@ -75,7 +76,6 @@ export { lowerFirst } from '../string/lowerFirst.mjs';
|
|
|
75
76
|
export { pascalCase } from '../string/pascalCase.mjs';
|
|
76
77
|
export { unescape } from '../string/unescape.mjs';
|
|
77
78
|
export { upperFirst } from '../string/upperFirst.mjs';
|
|
78
|
-
export { words } from '../string/words.mjs';
|
|
79
79
|
export { invariant } from '../util/invariant.mjs';
|
|
80
80
|
export { castArray } from './array/castArray.mjs';
|
|
81
81
|
export { chunk } from './array/chunk.mjs';
|
|
@@ -127,7 +127,7 @@ export { bind } from './function/bind.mjs';
|
|
|
127
127
|
export { bindKey } from './function/bindKey.mjs';
|
|
128
128
|
export { curry } from './function/curry.mjs';
|
|
129
129
|
export { curryRight } from './function/curryRight.mjs';
|
|
130
|
-
export { debounce } from './function/debounce.mjs';
|
|
130
|
+
export { DebouncedFunction as DebouncedFunc, DebouncedFunction, debounce } from './function/debounce.mjs';
|
|
131
131
|
export { defer } from './function/defer.mjs';
|
|
132
132
|
export { flip } from './function/flip.mjs';
|
|
133
133
|
export { flow } from './function/flow.mjs';
|
|
@@ -217,6 +217,7 @@ export { trim } from './string/trim.mjs';
|
|
|
217
217
|
export { trimEnd } from './string/trimEnd.mjs';
|
|
218
218
|
export { trimStart } from './string/trimStart.mjs';
|
|
219
219
|
export { upperCase } from './string/upperCase.mjs';
|
|
220
|
+
export { words } from './string/words.mjs';
|
|
220
221
|
export { constant } from './util/constant.mjs';
|
|
221
222
|
export { defaultTo } from './util/defaultTo.mjs';
|
|
222
223
|
export { eq } from './util/eq.mjs';
|
package/dist/compat/index.d.ts
CHANGED
|
@@ -38,6 +38,7 @@ export { noop } from '../function/noop.js';
|
|
|
38
38
|
export { once } from '../function/once.js';
|
|
39
39
|
export { partial } from '../function/partial.js';
|
|
40
40
|
export { partialRight } from '../function/partialRight.js';
|
|
41
|
+
export { ThrottledFunction } from '../function/throttle.js';
|
|
41
42
|
export { unary } from '../function/unary.js';
|
|
42
43
|
export { mean } from '../math/mean.js';
|
|
43
44
|
export { meanBy } from '../math/meanBy.js';
|
|
@@ -75,7 +76,6 @@ export { lowerFirst } from '../string/lowerFirst.js';
|
|
|
75
76
|
export { pascalCase } from '../string/pascalCase.js';
|
|
76
77
|
export { unescape } from '../string/unescape.js';
|
|
77
78
|
export { upperFirst } from '../string/upperFirst.js';
|
|
78
|
-
export { words } from '../string/words.js';
|
|
79
79
|
export { invariant } from '../util/invariant.js';
|
|
80
80
|
export { castArray } from './array/castArray.js';
|
|
81
81
|
export { chunk } from './array/chunk.js';
|
|
@@ -127,7 +127,7 @@ export { bind } from './function/bind.js';
|
|
|
127
127
|
export { bindKey } from './function/bindKey.js';
|
|
128
128
|
export { curry } from './function/curry.js';
|
|
129
129
|
export { curryRight } from './function/curryRight.js';
|
|
130
|
-
export { debounce } from './function/debounce.js';
|
|
130
|
+
export { DebouncedFunction as DebouncedFunc, DebouncedFunction, debounce } from './function/debounce.js';
|
|
131
131
|
export { defer } from './function/defer.js';
|
|
132
132
|
export { flip } from './function/flip.js';
|
|
133
133
|
export { flow } from './function/flow.js';
|
|
@@ -217,6 +217,7 @@ export { trim } from './string/trim.js';
|
|
|
217
217
|
export { trimEnd } from './string/trimEnd.js';
|
|
218
218
|
export { trimStart } from './string/trimStart.js';
|
|
219
219
|
export { upperCase } from './string/upperCase.js';
|
|
220
|
+
export { words } from './string/words.js';
|
|
220
221
|
export { constant } from './util/constant.js';
|
|
221
222
|
export { defaultTo } from './util/defaultTo.js';
|
|
222
223
|
export { eq } from './util/eq.js';
|
package/dist/compat/index.js
CHANGED
|
@@ -11,7 +11,7 @@ const randomInt = require('../_chunk/randomInt-CF7bZK.js');
|
|
|
11
11
|
const toMerged = require('../_chunk/toMerged-CPY8Ug.js');
|
|
12
12
|
const isPlainObject$1 = require('../_chunk/isPlainObject-octpoD.js');
|
|
13
13
|
const isWeakSet$1 = require('../_chunk/isWeakSet-CvIdTA.js');
|
|
14
|
-
const upperFirst = require('../_chunk/upperFirst-
|
|
14
|
+
const upperFirst = require('../_chunk/upperFirst-CorAVn.js');
|
|
15
15
|
const util_index = require('../util/index.js');
|
|
16
16
|
|
|
17
17
|
function castArray(value) {
|
|
@@ -1630,7 +1630,12 @@ function throttle(func, throttleMs = 0, options = {}) {
|
|
|
1630
1630
|
options = {};
|
|
1631
1631
|
}
|
|
1632
1632
|
const { leading = true, trailing = true, signal } = options;
|
|
1633
|
-
return debounce(func, throttleMs, {
|
|
1633
|
+
return debounce(func, throttleMs, {
|
|
1634
|
+
leading,
|
|
1635
|
+
trailing,
|
|
1636
|
+
signal,
|
|
1637
|
+
maxWait: throttleMs,
|
|
1638
|
+
});
|
|
1634
1639
|
}
|
|
1635
1640
|
|
|
1636
1641
|
function add(value, other) {
|
|
@@ -2602,6 +2607,12 @@ function upperCase(str) {
|
|
|
2602
2607
|
return upperFirst.upperCase(normalizeForCase(str));
|
|
2603
2608
|
}
|
|
2604
2609
|
|
|
2610
|
+
function words(str, pattern = upperFirst.CASE_SPLIT_PATTERN) {
|
|
2611
|
+
const input = toString(str);
|
|
2612
|
+
const words = Array.from(input.match(pattern) ?? []);
|
|
2613
|
+
return words.filter(x => x !== '');
|
|
2614
|
+
}
|
|
2615
|
+
|
|
2605
2616
|
function constant(value) {
|
|
2606
2617
|
return () => value;
|
|
2607
2618
|
}
|
|
@@ -2719,7 +2730,6 @@ exports.lowerFirst = upperFirst.lowerFirst;
|
|
|
2719
2730
|
exports.pascalCase = upperFirst.pascalCase;
|
|
2720
2731
|
exports.unescape = upperFirst.unescape;
|
|
2721
2732
|
exports.upperFirst = upperFirst.upperFirst;
|
|
2722
|
-
exports.words = upperFirst.words;
|
|
2723
2733
|
exports.invariant = util_index.invariant;
|
|
2724
2734
|
exports.add = add;
|
|
2725
2735
|
exports.ary = ary;
|
|
@@ -2874,5 +2884,6 @@ exports.unset = unset;
|
|
|
2874
2884
|
exports.unzip = unzip;
|
|
2875
2885
|
exports.upperCase = upperCase;
|
|
2876
2886
|
exports.without = without;
|
|
2887
|
+
exports.words = words;
|
|
2877
2888
|
exports.zip = zip;
|
|
2878
2889
|
exports.zipObjectDeep = zipObjectDeep;
|
package/dist/compat/index.mjs
CHANGED
|
@@ -70,7 +70,6 @@ export { delay } from '../promise/delay.mjs';
|
|
|
70
70
|
export { timeout } from '../promise/timeout.mjs';
|
|
71
71
|
export { withTimeout } from '../promise/withTimeout.mjs';
|
|
72
72
|
export { capitalize } from '../string/capitalize.mjs';
|
|
73
|
-
export { words } from '../string/words.mjs';
|
|
74
73
|
export { constantCase } from '../string/constantCase.mjs';
|
|
75
74
|
export { deburr } from '../string/deburr.mjs';
|
|
76
75
|
export { escapeRegExp } from '../string/escapeRegExp.mjs';
|
|
@@ -218,6 +217,7 @@ export { trim } from './string/trim.mjs';
|
|
|
218
217
|
export { trimEnd } from './string/trimEnd.mjs';
|
|
219
218
|
export { trimStart } from './string/trimStart.mjs';
|
|
220
219
|
export { upperCase } from './string/upperCase.mjs';
|
|
220
|
+
export { words } from './string/words.mjs';
|
|
221
221
|
export { constant } from './util/constant.mjs';
|
|
222
222
|
export { defaultTo } from './util/defaultTo.mjs';
|
|
223
223
|
export { iteratee } from './util/iteratee.mjs';
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Splits `string` into an array of its words.
|
|
3
|
+
*
|
|
4
|
+
* @param {string | object} str - The string or object that is to be split into words.
|
|
5
|
+
* @param {RegExp | string} [pattern] - The pattern to match words.
|
|
6
|
+
* @returns {string[]} - Returns the words of `string`.
|
|
7
|
+
*
|
|
8
|
+
* @example
|
|
9
|
+
* const wordsArray1 = words('fred, barney, & pebbles');
|
|
10
|
+
* // => ['fred', 'barney', 'pebbles']
|
|
11
|
+
*
|
|
12
|
+
*/
|
|
13
|
+
declare function words(str?: string | object, pattern?: RegExp | string): string[];
|
|
14
|
+
|
|
15
|
+
export { words };
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Splits `string` into an array of its words.
|
|
3
|
+
*
|
|
4
|
+
* @param {string | object} str - The string or object that is to be split into words.
|
|
5
|
+
* @param {RegExp | string} [pattern] - The pattern to match words.
|
|
6
|
+
* @returns {string[]} - Returns the words of `string`.
|
|
7
|
+
*
|
|
8
|
+
* @example
|
|
9
|
+
* const wordsArray1 = words('fred, barney, & pebbles');
|
|
10
|
+
* // => ['fred', 'barney', 'pebbles']
|
|
11
|
+
*
|
|
12
|
+
*/
|
|
13
|
+
declare function words(str?: string | object, pattern?: RegExp | string): string[];
|
|
14
|
+
|
|
15
|
+
export { words };
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { CASE_SPLIT_PATTERN } from '../../string/words.mjs';
|
|
2
|
+
import { toString } from '../util/toString.mjs';
|
|
3
|
+
|
|
4
|
+
function words(str, pattern = CASE_SPLIT_PATTERN) {
|
|
5
|
+
const input = toString(str);
|
|
6
|
+
const words = Array.from(input.match(pattern) ?? []);
|
|
7
|
+
return words.filter(x => x !== '');
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
export { words };
|
|
@@ -12,6 +12,28 @@ interface DebounceOptions {
|
|
|
12
12
|
*/
|
|
13
13
|
edges?: Array<'leading' | 'trailing'>;
|
|
14
14
|
}
|
|
15
|
+
interface DebouncedFunction<F extends (...args: any[]) => void> {
|
|
16
|
+
(...args: Parameters<F>): void;
|
|
17
|
+
/**
|
|
18
|
+
* Schedules the execution of the debounced function after the specified debounce delay.
|
|
19
|
+
* This method resets any existing timer, ensuring that the function is only invoked
|
|
20
|
+
* after the delay has elapsed since the last call to the debounced function.
|
|
21
|
+
* It is typically called internally whenever the debounced function is invoked.
|
|
22
|
+
*
|
|
23
|
+
* @returns {void}
|
|
24
|
+
*/
|
|
25
|
+
schedule: () => void;
|
|
26
|
+
/**
|
|
27
|
+
* Cancels any pending execution of the debounced function.
|
|
28
|
+
* This method clears the active timer and resets any stored context or arguments.
|
|
29
|
+
*/
|
|
30
|
+
cancel: () => void;
|
|
31
|
+
/**
|
|
32
|
+
* Immediately invokes the debounced function if there is a pending execution.
|
|
33
|
+
* This method also cancels the current timer, ensuring that the function executes right away.
|
|
34
|
+
*/
|
|
35
|
+
flush: () => void;
|
|
36
|
+
}
|
|
15
37
|
/**
|
|
16
38
|
* Creates a debounced function that delays invoking the provided function until after `debounceMs` milliseconds
|
|
17
39
|
* have elapsed since the last time the debounced function was invoked. The debounced function also has a `cancel`
|
|
@@ -47,26 +69,6 @@ interface DebounceOptions {
|
|
|
47
69
|
* // Will cancel the debounced function call
|
|
48
70
|
* controller.abort();
|
|
49
71
|
*/
|
|
50
|
-
declare function debounce<F extends (...args: any[]) => void>(func: F, debounceMs: number, { signal, edges }?: DebounceOptions):
|
|
51
|
-
/**
|
|
52
|
-
* Schedules the execution of the debounced function after the specified debounce delay.
|
|
53
|
-
* This method resets any existing timer, ensuring that the function is only invoked
|
|
54
|
-
* after the delay has elapsed since the last call to the debounced function.
|
|
55
|
-
* It is typically called internally whenever the debounced function is invoked.
|
|
56
|
-
*
|
|
57
|
-
* @returns {void}
|
|
58
|
-
*/
|
|
59
|
-
schedule: () => void;
|
|
60
|
-
/**
|
|
61
|
-
* Cancels any pending execution of the debounced function.
|
|
62
|
-
* This method clears the active timer and resets any stored context or arguments.
|
|
63
|
-
*/
|
|
64
|
-
cancel: () => void;
|
|
65
|
-
/**
|
|
66
|
-
* Immediately invokes the debounced function if there is a pending execution.
|
|
67
|
-
* This method also cancels the current timer, ensuring that the function executes right away.
|
|
68
|
-
*/
|
|
69
|
-
flush: () => void;
|
|
70
|
-
};
|
|
72
|
+
declare function debounce<F extends (...args: any[]) => void>(func: F, debounceMs: number, { signal, edges }?: DebounceOptions): DebouncedFunction<F>;
|
|
71
73
|
|
|
72
|
-
export { debounce };
|
|
74
|
+
export { type DebouncedFunction, debounce };
|
|
@@ -12,6 +12,28 @@ interface DebounceOptions {
|
|
|
12
12
|
*/
|
|
13
13
|
edges?: Array<'leading' | 'trailing'>;
|
|
14
14
|
}
|
|
15
|
+
interface DebouncedFunction<F extends (...args: any[]) => void> {
|
|
16
|
+
(...args: Parameters<F>): void;
|
|
17
|
+
/**
|
|
18
|
+
* Schedules the execution of the debounced function after the specified debounce delay.
|
|
19
|
+
* This method resets any existing timer, ensuring that the function is only invoked
|
|
20
|
+
* after the delay has elapsed since the last call to the debounced function.
|
|
21
|
+
* It is typically called internally whenever the debounced function is invoked.
|
|
22
|
+
*
|
|
23
|
+
* @returns {void}
|
|
24
|
+
*/
|
|
25
|
+
schedule: () => void;
|
|
26
|
+
/**
|
|
27
|
+
* Cancels any pending execution of the debounced function.
|
|
28
|
+
* This method clears the active timer and resets any stored context or arguments.
|
|
29
|
+
*/
|
|
30
|
+
cancel: () => void;
|
|
31
|
+
/**
|
|
32
|
+
* Immediately invokes the debounced function if there is a pending execution.
|
|
33
|
+
* This method also cancels the current timer, ensuring that the function executes right away.
|
|
34
|
+
*/
|
|
35
|
+
flush: () => void;
|
|
36
|
+
}
|
|
15
37
|
/**
|
|
16
38
|
* Creates a debounced function that delays invoking the provided function until after `debounceMs` milliseconds
|
|
17
39
|
* have elapsed since the last time the debounced function was invoked. The debounced function also has a `cancel`
|
|
@@ -47,26 +69,6 @@ interface DebounceOptions {
|
|
|
47
69
|
* // Will cancel the debounced function call
|
|
48
70
|
* controller.abort();
|
|
49
71
|
*/
|
|
50
|
-
declare function debounce<F extends (...args: any[]) => void>(func: F, debounceMs: number, { signal, edges }?: DebounceOptions):
|
|
51
|
-
/**
|
|
52
|
-
* Schedules the execution of the debounced function after the specified debounce delay.
|
|
53
|
-
* This method resets any existing timer, ensuring that the function is only invoked
|
|
54
|
-
* after the delay has elapsed since the last call to the debounced function.
|
|
55
|
-
* It is typically called internally whenever the debounced function is invoked.
|
|
56
|
-
*
|
|
57
|
-
* @returns {void}
|
|
58
|
-
*/
|
|
59
|
-
schedule: () => void;
|
|
60
|
-
/**
|
|
61
|
-
* Cancels any pending execution of the debounced function.
|
|
62
|
-
* This method clears the active timer and resets any stored context or arguments.
|
|
63
|
-
*/
|
|
64
|
-
cancel: () => void;
|
|
65
|
-
/**
|
|
66
|
-
* Immediately invokes the debounced function if there is a pending execution.
|
|
67
|
-
* This method also cancels the current timer, ensuring that the function executes right away.
|
|
68
|
-
*/
|
|
69
|
-
flush: () => void;
|
|
70
|
-
};
|
|
72
|
+
declare function debounce<F extends (...args: any[]) => void>(func: F, debounceMs: number, { signal, edges }?: DebounceOptions): DebouncedFunction<F>;
|
|
71
73
|
|
|
72
|
-
export { debounce };
|
|
74
|
+
export { type DebouncedFunction, debounce };
|
|
@@ -3,7 +3,7 @@ export { ary } from './ary.mjs';
|
|
|
3
3
|
export { before } from './before.mjs';
|
|
4
4
|
export { curry } from './curry.mjs';
|
|
5
5
|
export { curryRight } from './curryRight.mjs';
|
|
6
|
-
export { debounce } from './debounce.mjs';
|
|
6
|
+
export { DebouncedFunction, debounce } from './debounce.mjs';
|
|
7
7
|
export { flow } from './flow.mjs';
|
|
8
8
|
export { flowRight } from './flowRight.mjs';
|
|
9
9
|
export { identity } from './identity.mjs';
|
|
@@ -15,5 +15,5 @@ export { partial } from './partial.mjs';
|
|
|
15
15
|
export { partialRight } from './partialRight.mjs';
|
|
16
16
|
export { rest } from './rest.mjs';
|
|
17
17
|
export { spread } from './spread.mjs';
|
|
18
|
-
export { throttle } from './throttle.mjs';
|
|
18
|
+
export { ThrottledFunction, throttle } from './throttle.mjs';
|
|
19
19
|
export { unary } from './unary.mjs';
|
package/dist/function/index.d.ts
CHANGED
|
@@ -3,7 +3,7 @@ export { ary } from './ary.js';
|
|
|
3
3
|
export { before } from './before.js';
|
|
4
4
|
export { curry } from './curry.js';
|
|
5
5
|
export { curryRight } from './curryRight.js';
|
|
6
|
-
export { debounce } from './debounce.js';
|
|
6
|
+
export { DebouncedFunction, debounce } from './debounce.js';
|
|
7
7
|
export { flow } from './flow.js';
|
|
8
8
|
export { flowRight } from './flowRight.js';
|
|
9
9
|
export { identity } from './identity.js';
|
|
@@ -15,5 +15,5 @@ export { partial } from './partial.js';
|
|
|
15
15
|
export { partialRight } from './partialRight.js';
|
|
16
16
|
export { rest } from './rest.js';
|
|
17
17
|
export { spread } from './spread.js';
|
|
18
|
-
export { throttle } from './throttle.js';
|
|
18
|
+
export { ThrottledFunction, throttle } from './throttle.js';
|
|
19
19
|
export { unary } from './unary.js';
|
|
@@ -12,6 +12,11 @@ interface ThrottleOptions {
|
|
|
12
12
|
*/
|
|
13
13
|
edges?: Array<'leading' | 'trailing'>;
|
|
14
14
|
}
|
|
15
|
+
interface ThrottledFunction<F extends (...args: any[]) => void> {
|
|
16
|
+
(...args: Parameters<F>): void;
|
|
17
|
+
cancel: () => void;
|
|
18
|
+
flush: () => void;
|
|
19
|
+
}
|
|
15
20
|
/**
|
|
16
21
|
* Creates a throttled function that only invokes the provided function at most once
|
|
17
22
|
* per every `throttleMs` milliseconds. Subsequent calls to the throttled function
|
|
@@ -38,9 +43,6 @@ interface ThrottleOptions {
|
|
|
38
43
|
* throttledFunction(); // Will log 'Function executed'
|
|
39
44
|
* }, 1000);
|
|
40
45
|
*/
|
|
41
|
-
declare function throttle<F extends (...args: any[]) => void>(func: F, throttleMs: number, { signal, edges }?: ThrottleOptions):
|
|
42
|
-
cancel: () => void;
|
|
43
|
-
flush: () => void;
|
|
44
|
-
};
|
|
46
|
+
declare function throttle<F extends (...args: any[]) => void>(func: F, throttleMs: number, { signal, edges }?: ThrottleOptions): ThrottledFunction<F>;
|
|
45
47
|
|
|
46
|
-
export { throttle };
|
|
48
|
+
export { type ThrottledFunction, throttle };
|
|
@@ -12,6 +12,11 @@ interface ThrottleOptions {
|
|
|
12
12
|
*/
|
|
13
13
|
edges?: Array<'leading' | 'trailing'>;
|
|
14
14
|
}
|
|
15
|
+
interface ThrottledFunction<F extends (...args: any[]) => void> {
|
|
16
|
+
(...args: Parameters<F>): void;
|
|
17
|
+
cancel: () => void;
|
|
18
|
+
flush: () => void;
|
|
19
|
+
}
|
|
15
20
|
/**
|
|
16
21
|
* Creates a throttled function that only invokes the provided function at most once
|
|
17
22
|
* per every `throttleMs` milliseconds. Subsequent calls to the throttled function
|
|
@@ -38,9 +43,6 @@ interface ThrottleOptions {
|
|
|
38
43
|
* throttledFunction(); // Will log 'Function executed'
|
|
39
44
|
* }, 1000);
|
|
40
45
|
*/
|
|
41
|
-
declare function throttle<F extends (...args: any[]) => void>(func: F, throttleMs: number, { signal, edges }?: ThrottleOptions):
|
|
42
|
-
cancel: () => void;
|
|
43
|
-
flush: () => void;
|
|
44
|
-
};
|
|
46
|
+
declare function throttle<F extends (...args: any[]) => void>(func: F, throttleMs: number, { signal, edges }?: ThrottleOptions): ThrottledFunction<F>;
|
|
45
47
|
|
|
46
|
-
export { throttle };
|
|
48
|
+
export { type ThrottledFunction, throttle };
|
package/dist/index.d.mts
CHANGED
|
@@ -62,7 +62,7 @@ export { ary } from './function/ary.mjs';
|
|
|
62
62
|
export { before } from './function/before.mjs';
|
|
63
63
|
export { curry } from './function/curry.mjs';
|
|
64
64
|
export { curryRight } from './function/curryRight.mjs';
|
|
65
|
-
export { debounce } from './function/debounce.mjs';
|
|
65
|
+
export { DebouncedFunction, debounce } from './function/debounce.mjs';
|
|
66
66
|
export { flow } from './function/flow.mjs';
|
|
67
67
|
export { flowRight } from './function/flowRight.mjs';
|
|
68
68
|
export { identity } from './function/identity.mjs';
|
|
@@ -74,7 +74,7 @@ export { partial } from './function/partial.mjs';
|
|
|
74
74
|
export { partialRight } from './function/partialRight.mjs';
|
|
75
75
|
export { rest } from './function/rest.mjs';
|
|
76
76
|
export { spread } from './function/spread.mjs';
|
|
77
|
-
export { throttle } from './function/throttle.mjs';
|
|
77
|
+
export { ThrottledFunction, throttle } from './function/throttle.mjs';
|
|
78
78
|
export { unary } from './function/unary.mjs';
|
|
79
79
|
export { clamp } from './math/clamp.mjs';
|
|
80
80
|
export { inRange } from './math/inRange.mjs';
|
package/dist/index.d.ts
CHANGED
|
@@ -62,7 +62,7 @@ export { ary } from './function/ary.js';
|
|
|
62
62
|
export { before } from './function/before.js';
|
|
63
63
|
export { curry } from './function/curry.js';
|
|
64
64
|
export { curryRight } from './function/curryRight.js';
|
|
65
|
-
export { debounce } from './function/debounce.js';
|
|
65
|
+
export { DebouncedFunction, debounce } from './function/debounce.js';
|
|
66
66
|
export { flow } from './function/flow.js';
|
|
67
67
|
export { flowRight } from './function/flowRight.js';
|
|
68
68
|
export { identity } from './function/identity.js';
|
|
@@ -74,7 +74,7 @@ export { partial } from './function/partial.js';
|
|
|
74
74
|
export { partialRight } from './function/partialRight.js';
|
|
75
75
|
export { rest } from './function/rest.js';
|
|
76
76
|
export { spread } from './function/spread.js';
|
|
77
|
-
export { throttle } from './function/throttle.js';
|
|
77
|
+
export { ThrottledFunction, throttle } from './function/throttle.js';
|
|
78
78
|
export { unary } from './function/unary.js';
|
|
79
79
|
export { clamp } from './math/clamp.js';
|
|
80
80
|
export { inRange } from './math/inRange.js';
|
package/dist/index.js
CHANGED
|
@@ -16,7 +16,7 @@ const object_index = require('./object/index.js');
|
|
|
16
16
|
const isWeakSet = require('./_chunk/isWeakSet-CvIdTA.js');
|
|
17
17
|
const predicate_index = require('./predicate/index.js');
|
|
18
18
|
const isPlainObject = require('./_chunk/isPlainObject-octpoD.js');
|
|
19
|
-
const upperFirst = require('./_chunk/upperFirst-
|
|
19
|
+
const upperFirst = require('./_chunk/upperFirst-CorAVn.js');
|
|
20
20
|
const string_index = require('./string/index.js');
|
|
21
21
|
const util_index = require('./util/index.js');
|
|
22
22
|
|
package/dist/string/index.js
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
4
4
|
|
|
5
|
-
const upperFirst = require('../_chunk/upperFirst-
|
|
5
|
+
const upperFirst = require('../_chunk/upperFirst-CorAVn.js');
|
|
6
6
|
|
|
7
7
|
function startCase(str) {
|
|
8
8
|
const words = upperFirst.words(str.trim());
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "es-toolkit",
|
|
3
3
|
"description": "A state-of-the-art, high-performance JavaScript utility library with a small bundle size and strong type annotations.",
|
|
4
|
-
"version": "1.27.0-dev.
|
|
4
|
+
"version": "1.27.0-dev.898+578c0000",
|
|
5
5
|
"homepage": "https://es-toolkit.slash.page",
|
|
6
6
|
"bugs": "https://github.com/toss/es-toolkit/issues",
|
|
7
7
|
"repository": {
|