@ls-stack/utils 3.56.0 → 3.58.0

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.
Files changed (38) hide show
  1. package/dist/arrayUtils.cjs +24 -0
  2. package/dist/arrayUtils.d.cts +45 -20
  3. package/dist/arrayUtils.d.ts +45 -20
  4. package/dist/arrayUtils.js +5 -1
  5. package/dist/asyncQueue.js +2 -2
  6. package/dist/cache.js +3 -3
  7. package/dist/{chunk-5MNYPLZI.js → chunk-6FBIEPWU.js} +1 -1
  8. package/dist/{chunk-27AL66CH.js → chunk-BT3UMATU.js} +23 -1
  9. package/dist/{chunk-NW5H5EW7.js → chunk-CCUPDGSZ.js} +44 -12
  10. package/dist/chunk-DBOWTYR4.js +49 -0
  11. package/dist/{chunk-AULH7VMS.js → chunk-DX2524CZ.js} +1 -1
  12. package/dist/{chunk-6CG6JZKB.js → chunk-LBBC55GE.js} +1 -1
  13. package/dist/{chunk-Y76LZUOB.js → chunk-WNFRB7P6.js} +1 -1
  14. package/dist/concurrentCalls.js +4 -4
  15. package/dist/createThrottleController.js +2 -2
  16. package/dist/debounce.cjs +44 -12
  17. package/dist/debounce.d.cts +9 -0
  18. package/dist/debounce.d.ts +9 -0
  19. package/dist/debounce.js +1 -1
  20. package/dist/filterObjectOrArrayKeys.js +2 -2
  21. package/dist/interpolate.js +1 -1
  22. package/dist/iteratorUtils.cjs +73 -0
  23. package/dist/iteratorUtils.d.cts +10 -0
  24. package/dist/iteratorUtils.d.ts +10 -0
  25. package/dist/iteratorUtils.js +44 -0
  26. package/dist/matchPath.js +3 -3
  27. package/dist/mathUtils.cjs +28 -2
  28. package/dist/mathUtils.d.cts +48 -1
  29. package/dist/mathUtils.d.ts +48 -1
  30. package/dist/mathUtils.js +11 -3
  31. package/dist/objUtils.js +2 -2
  32. package/dist/serializeXML.js +1 -1
  33. package/dist/testUtils.js +4 -4
  34. package/dist/throttle.cjs +43 -11
  35. package/dist/throttle.js +1 -1
  36. package/dist/time.js +2 -2
  37. package/package.json +5 -1
  38. package/dist/chunk-HTCYUMDR.js +0 -27
@@ -27,11 +27,20 @@ interface DebouncedFunc<T extends (...args: any[]) => void> {
27
27
  * debounced function was never invoked.
28
28
  */
29
29
  flush: () => ReturnType<T> | undefined;
30
+ /** Return true if the debounced function still has a scheduled run. */
31
+ pending: () => boolean;
32
+ /** Update the debounced function with a new callback. */
33
+ updateCb: (callback: T) => void;
34
+ /** Update the debounce wait and options while keeping scheduled runs. */
35
+ updateParams: (wait: number, options?: DebounceOptions) => void;
30
36
  }
31
37
  declare function debounce<T extends (...args: any[]) => void>(func: T, wait: number, options?: DebounceOptions): DebouncedFunc<T>;
32
38
  declare function isDebouncedFn<T extends (...args: any[]) => void>(fn: T): fn is T & {
33
39
  cancel: () => void;
34
40
  flush: () => ReturnType<T> | undefined;
41
+ pending: () => boolean;
42
+ updateCb: (callback: T) => void;
43
+ updateParams: (wait: number, options?: DebounceOptions) => void;
35
44
  };
36
45
 
37
46
  export { type DebounceOptions, type DebouncedFunc, debounce, isDebouncedFn };
package/dist/debounce.js CHANGED
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  debounce,
3
3
  isDebouncedFn
4
- } from "./chunk-NW5H5EW7.js";
4
+ } from "./chunk-CCUPDGSZ.js";
5
5
  export {
6
6
  debounce,
7
7
  isDebouncedFn
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  filterObjectOrArrayKeys
3
- } from "./chunk-6CG6JZKB.js";
4
- import "./chunk-27AL66CH.js";
3
+ } from "./chunk-LBBC55GE.js";
4
+ import "./chunk-BT3UMATU.js";
5
5
  import "./chunk-C2SVCIWE.js";
6
6
  import "./chunk-JF2MDHOJ.js";
7
7
  export {
@@ -2,7 +2,7 @@ import {
2
2
  clampMax,
3
3
  clampMin,
4
4
  clampRange
5
- } from "./chunk-HTCYUMDR.js";
5
+ } from "./chunk-DBOWTYR4.js";
6
6
  import {
7
7
  invariant
8
8
  } from "./chunk-C2SVCIWE.js";
@@ -0,0 +1,73 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+
20
+ // src/iteratorUtils.ts
21
+ var iteratorUtils_exports = {};
22
+ __export(iteratorUtils_exports, {
23
+ enumerate: () => enumerate,
24
+ range: () => range,
25
+ rangeArray: () => rangeArray,
26
+ withIsLast: () => withIsLast,
27
+ withPrevious: () => withPrevious
28
+ });
29
+ module.exports = __toCommonJS(iteratorUtils_exports);
30
+ function* enumerate(iter, start = 0) {
31
+ let index = start;
32
+ for (const item of iter) {
33
+ yield [index, item];
34
+ index++;
35
+ }
36
+ }
37
+ function* withIsLast(array) {
38
+ let index = 0;
39
+ for (const item of array) {
40
+ const isLast = index === array.length - 1;
41
+ yield [isLast, item, index];
42
+ index++;
43
+ }
44
+ }
45
+ function* withPrevious(iter) {
46
+ let prev = void 0;
47
+ for (const current of iter) {
48
+ yield { prev, current };
49
+ prev = current;
50
+ }
51
+ }
52
+ function* range(start, end, step = 1) {
53
+ if (start > end) {
54
+ for (let i = start; i >= end; i -= step) {
55
+ yield i;
56
+ }
57
+ } else {
58
+ for (let i = start; i <= end; i += step) {
59
+ yield i;
60
+ }
61
+ }
62
+ }
63
+ function rangeArray(start, end, step = 1) {
64
+ return [...range(start, end, step)];
65
+ }
66
+ // Annotate the CommonJS export names for ESM import in node:
67
+ 0 && (module.exports = {
68
+ enumerate,
69
+ range,
70
+ rangeArray,
71
+ withIsLast,
72
+ withPrevious
73
+ });
@@ -0,0 +1,10 @@
1
+ declare function enumerate<T>(iter: Iterable<T>, start?: number): Generator<[number, T]>;
2
+ declare function withIsLast<T>(array: T[]): Generator<[isLast: boolean, item: T, index: number]>;
3
+ declare function withPrevious<T>(iter: Iterable<T>): Generator<{
4
+ prev: T | undefined;
5
+ current: T;
6
+ }>;
7
+ declare function range(start: number, end: number, step?: number): Generator<number>;
8
+ declare function rangeArray(start: number, end: number, step?: number): number[];
9
+
10
+ export { enumerate, range, rangeArray, withIsLast, withPrevious };
@@ -0,0 +1,10 @@
1
+ declare function enumerate<T>(iter: Iterable<T>, start?: number): Generator<[number, T]>;
2
+ declare function withIsLast<T>(array: T[]): Generator<[isLast: boolean, item: T, index: number]>;
3
+ declare function withPrevious<T>(iter: Iterable<T>): Generator<{
4
+ prev: T | undefined;
5
+ current: T;
6
+ }>;
7
+ declare function range(start: number, end: number, step?: number): Generator<number>;
8
+ declare function rangeArray(start: number, end: number, step?: number): number[];
9
+
10
+ export { enumerate, range, rangeArray, withIsLast, withPrevious };
@@ -0,0 +1,44 @@
1
+ // src/iteratorUtils.ts
2
+ function* enumerate(iter, start = 0) {
3
+ let index = start;
4
+ for (const item of iter) {
5
+ yield [index, item];
6
+ index++;
7
+ }
8
+ }
9
+ function* withIsLast(array) {
10
+ let index = 0;
11
+ for (const item of array) {
12
+ const isLast = index === array.length - 1;
13
+ yield [isLast, item, index];
14
+ index++;
15
+ }
16
+ }
17
+ function* withPrevious(iter) {
18
+ let prev = void 0;
19
+ for (const current of iter) {
20
+ yield { prev, current };
21
+ prev = current;
22
+ }
23
+ }
24
+ function* range(start, end, step = 1) {
25
+ if (start > end) {
26
+ for (let i = start; i >= end; i -= step) {
27
+ yield i;
28
+ }
29
+ } else {
30
+ for (let i = start; i <= end; i += step) {
31
+ yield i;
32
+ }
33
+ }
34
+ }
35
+ function rangeArray(start, end, step = 1) {
36
+ return [...range(start, end, step)];
37
+ }
38
+ export {
39
+ enumerate,
40
+ range,
41
+ rangeArray,
42
+ withIsLast,
43
+ withPrevious
44
+ };
package/dist/matchPath.js CHANGED
@@ -1,8 +1,8 @@
1
1
  import {
2
2
  fastCache
3
- } from "./chunk-AULH7VMS.js";
4
- import "./chunk-5MNYPLZI.js";
5
- import "./chunk-HTCYUMDR.js";
3
+ } from "./chunk-DX2524CZ.js";
4
+ import "./chunk-6FBIEPWU.js";
5
+ import "./chunk-DBOWTYR4.js";
6
6
  import "./chunk-II4R3VVX.js";
7
7
  import "./chunk-C2SVCIWE.js";
8
8
  import "./chunk-JF2MDHOJ.js";
@@ -20,11 +20,15 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
20
20
  // src/mathUtils.ts
21
21
  var mathUtils_exports = {};
22
22
  __export(mathUtils_exports, {
23
+ ceilToStep: () => ceilToStep,
23
24
  clamp: () => clamp,
24
25
  clampMax: () => clampMax,
25
26
  clampMin: () => clampMin,
26
27
  clampRange: () => clampRange,
27
- fixFloatingPointNumber: () => fixFloatingPointNumber
28
+ fixFloatingPointNumber: () => fixFloatingPointNumber,
29
+ floorToStep: () => floorToStep,
30
+ round: () => round,
31
+ roundToStep: () => roundToStep
28
32
  });
29
33
  module.exports = __toCommonJS(mathUtils_exports);
30
34
  function clampMax(value, max) {
@@ -45,11 +49,33 @@ function clamp(num, min, max) {
45
49
  function fixFloatingPointNumber(value) {
46
50
  return Number(value.toPrecision(15));
47
51
  }
52
+ function roundToStep(value, step, offset = 0) {
53
+ const inv = 1 / step;
54
+ const snapped = Math.round((value - offset) * inv) / inv + offset;
55
+ return Number(snapped.toFixed(12));
56
+ }
57
+ function floorToStep(value, step, offset = 0) {
58
+ const inv = 1 / step;
59
+ const snapped = Math.floor((value - offset) * inv) / inv + offset;
60
+ return Number(snapped.toFixed(12));
61
+ }
62
+ function ceilToStep(value, step, offset = 0) {
63
+ const inv = 1 / step;
64
+ const snapped = Math.ceil((value - offset) * inv) / inv + offset;
65
+ return Number(snapped.toFixed(12));
66
+ }
67
+ function round(num, precision) {
68
+ return Math.round(num * 10 ** precision) / 10 ** precision;
69
+ }
48
70
  // Annotate the CommonJS export names for ESM import in node:
49
71
  0 && (module.exports = {
72
+ ceilToStep,
50
73
  clamp,
51
74
  clampMax,
52
75
  clampMin,
53
76
  clampRange,
54
- fixFloatingPointNumber
77
+ fixFloatingPointNumber,
78
+ floorToStep,
79
+ round,
80
+ roundToStep
55
81
  });
@@ -3,5 +3,52 @@ declare function clampMin(value: number, min: number): number;
3
3
  declare function clampRange(num: number, v1: number, v2: number): number;
4
4
  declare function clamp(num: number, min: number, max: number): number;
5
5
  declare function fixFloatingPointNumber(value: number): number;
6
+ /**
7
+ * Rounds a number to the nearest multiple of the specified step value.
8
+ *
9
+ * @param value - The number to round
10
+ * @param step - The step size to round to
11
+ * @param offset - Optional offset to shift the rounding grid
12
+ * @returns The rounded value
13
+ *
14
+ * @example
15
+ * roundToStep(23, 5) // 25 (nearest multiple of 5)
16
+ */
17
+ declare function roundToStep(value: number, step: number, offset?: number): number;
18
+ /**
19
+ * Floors a number down to the nearest multiple of the specified step value.
20
+ *
21
+ * @param value - The number to floor
22
+ * @param step - The step size to floor to
23
+ * @param offset - Optional offset to shift the flooring grid
24
+ * @returns The floored value
25
+ *
26
+ * @example
27
+ * floorToStep(23, 5) // 20 (largest multiple of 5 ≤ 23)
28
+ */
29
+ declare function floorToStep(value: number, step: number, offset?: number): number;
30
+ /**
31
+ * Ceils a number up to the nearest multiple of the specified step value.
32
+ *
33
+ * @param value - The number to ceil
34
+ * @param step - The step size to ceil to
35
+ * @param offset - Optional offset to shift the ceiling grid
36
+ * @returns The ceiled value
37
+ *
38
+ * @example
39
+ * ceilToStep(23, 5) // 25 (smallest multiple of 5 ≥ 23)
40
+ */
41
+ declare function ceilToStep(value: number, step: number, offset?: number): number;
42
+ /**
43
+ * Rounds a number to the specified number of decimal places.
44
+ *
45
+ * @param num - The number to round
46
+ * @param precision - Number of decimal places
47
+ * @returns The rounded number
48
+ *
49
+ * @example
50
+ * round(3.14159, 2) // 3.14
51
+ */
52
+ declare function round(num: number, precision: number): number;
6
53
 
7
- export { clamp, clampMax, clampMin, clampRange, fixFloatingPointNumber };
54
+ export { ceilToStep, clamp, clampMax, clampMin, clampRange, fixFloatingPointNumber, floorToStep, round, roundToStep };
@@ -3,5 +3,52 @@ declare function clampMin(value: number, min: number): number;
3
3
  declare function clampRange(num: number, v1: number, v2: number): number;
4
4
  declare function clamp(num: number, min: number, max: number): number;
5
5
  declare function fixFloatingPointNumber(value: number): number;
6
+ /**
7
+ * Rounds a number to the nearest multiple of the specified step value.
8
+ *
9
+ * @param value - The number to round
10
+ * @param step - The step size to round to
11
+ * @param offset - Optional offset to shift the rounding grid
12
+ * @returns The rounded value
13
+ *
14
+ * @example
15
+ * roundToStep(23, 5) // 25 (nearest multiple of 5)
16
+ */
17
+ declare function roundToStep(value: number, step: number, offset?: number): number;
18
+ /**
19
+ * Floors a number down to the nearest multiple of the specified step value.
20
+ *
21
+ * @param value - The number to floor
22
+ * @param step - The step size to floor to
23
+ * @param offset - Optional offset to shift the flooring grid
24
+ * @returns The floored value
25
+ *
26
+ * @example
27
+ * floorToStep(23, 5) // 20 (largest multiple of 5 ≤ 23)
28
+ */
29
+ declare function floorToStep(value: number, step: number, offset?: number): number;
30
+ /**
31
+ * Ceils a number up to the nearest multiple of the specified step value.
32
+ *
33
+ * @param value - The number to ceil
34
+ * @param step - The step size to ceil to
35
+ * @param offset - Optional offset to shift the ceiling grid
36
+ * @returns The ceiled value
37
+ *
38
+ * @example
39
+ * ceilToStep(23, 5) // 25 (smallest multiple of 5 ≥ 23)
40
+ */
41
+ declare function ceilToStep(value: number, step: number, offset?: number): number;
42
+ /**
43
+ * Rounds a number to the specified number of decimal places.
44
+ *
45
+ * @param num - The number to round
46
+ * @param precision - Number of decimal places
47
+ * @returns The rounded number
48
+ *
49
+ * @example
50
+ * round(3.14159, 2) // 3.14
51
+ */
52
+ declare function round(num: number, precision: number): number;
6
53
 
7
- export { clamp, clampMax, clampMin, clampRange, fixFloatingPointNumber };
54
+ export { ceilToStep, clamp, clampMax, clampMin, clampRange, fixFloatingPointNumber, floorToStep, round, roundToStep };
package/dist/mathUtils.js CHANGED
@@ -1,14 +1,22 @@
1
1
  import {
2
+ ceilToStep,
2
3
  clamp,
3
4
  clampMax,
4
5
  clampMin,
5
6
  clampRange,
6
- fixFloatingPointNumber
7
- } from "./chunk-HTCYUMDR.js";
7
+ fixFloatingPointNumber,
8
+ floorToStep,
9
+ round,
10
+ roundToStep
11
+ } from "./chunk-DBOWTYR4.js";
8
12
  export {
13
+ ceilToStep,
9
14
  clamp,
10
15
  clampMax,
11
16
  clampMin,
12
17
  clampRange,
13
- fixFloatingPointNumber
18
+ fixFloatingPointNumber,
19
+ floorToStep,
20
+ round,
21
+ roundToStep
14
22
  };
package/dist/objUtils.js CHANGED
@@ -9,9 +9,9 @@ import {
9
9
  pick,
10
10
  rejectObjUndefinedValues,
11
11
  sortObjectKeys
12
- } from "./chunk-Y76LZUOB.js";
12
+ } from "./chunk-WNFRB7P6.js";
13
13
  import "./chunk-GMJTLFM6.js";
14
- import "./chunk-27AL66CH.js";
14
+ import "./chunk-BT3UMATU.js";
15
15
  import "./chunk-C2SVCIWE.js";
16
16
  import "./chunk-JF2MDHOJ.js";
17
17
  export {
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  filterAndMap
3
- } from "./chunk-27AL66CH.js";
3
+ } from "./chunk-BT3UMATU.js";
4
4
  import "./chunk-C2SVCIWE.js";
5
5
  import {
6
6
  isTruthy
package/dist/testUtils.js CHANGED
@@ -4,11 +4,11 @@ import {
4
4
  import {
5
5
  omit,
6
6
  pick
7
- } from "./chunk-Y76LZUOB.js";
7
+ } from "./chunk-WNFRB7P6.js";
8
8
  import "./chunk-GMJTLFM6.js";
9
9
  import {
10
10
  filterObjectOrArrayKeys
11
- } from "./chunk-6CG6JZKB.js";
11
+ } from "./chunk-LBBC55GE.js";
12
12
  import "./chunk-IATIXMCE.js";
13
13
  import {
14
14
  deepEqual
@@ -21,12 +21,12 @@ import {
21
21
  } from "./chunk-DFXNVEH6.js";
22
22
  import {
23
23
  clampMin
24
- } from "./chunk-HTCYUMDR.js";
24
+ } from "./chunk-DBOWTYR4.js";
25
25
  import "./chunk-BM4PYVOX.js";
26
26
  import {
27
27
  arrayWithPrevAndIndex,
28
28
  filterAndMap
29
- } from "./chunk-27AL66CH.js";
29
+ } from "./chunk-BT3UMATU.js";
30
30
  import {
31
31
  isObject
32
32
  } from "./chunk-C2SVCIWE.js";
package/dist/throttle.cjs CHANGED
@@ -27,6 +27,9 @@ module.exports = __toCommonJS(throttle_exports);
27
27
 
28
28
  // src/debounce.ts
29
29
  function debounce(func, wait, options) {
30
+ let currentCallback = func;
31
+ let waitMs = wait;
32
+ let currentOptions = options;
30
33
  let lastArgs;
31
34
  let lastThis;
32
35
  let maxWait;
@@ -37,35 +40,37 @@ function debounce(func, wait, options) {
37
40
  let leading = false;
38
41
  let maxing = false;
39
42
  let trailing = true;
40
- if (options) {
41
- leading = !!options.leading;
42
- maxing = "maxWait" in options;
43
- maxWait = maxing ? Math.max(options.maxWait || 0, wait) : maxWait;
44
- trailing = "trailing" in options ? !!options.trailing : trailing;
43
+ function applyOptions() {
44
+ const opts = currentOptions;
45
+ leading = !!opts?.leading;
46
+ trailing = opts && "trailing" in opts ? !!opts.trailing : true;
47
+ maxing = !!(opts && "maxWait" in opts);
48
+ maxWait = maxing ? Math.max(opts?.maxWait ?? 0, waitMs) : void 0;
45
49
  }
50
+ applyOptions();
46
51
  function invokeFunc(time) {
47
52
  const args = lastArgs;
48
53
  const thisArg = lastThis;
49
54
  lastArgs = lastThis = void 0;
50
55
  lastInvokeTime = time;
51
- result = func.apply(thisArg, args);
56
+ result = currentCallback.apply(thisArg, args);
52
57
  return result;
53
58
  }
54
59
  function leadingEdge(time) {
55
60
  lastInvokeTime = time;
56
- timerId = setTimeout(timerExpired, wait);
61
+ timerId = setTimeout(timerExpired, waitMs);
57
62
  return leading ? invokeFunc(time) : result;
58
63
  }
59
64
  function remainingWait(time) {
60
65
  const timeSinceLastCall = time - (lastCallTime ?? 0);
61
66
  const timeSinceLastInvoke = time - lastInvokeTime;
62
- const timeWaiting = wait - timeSinceLastCall;
67
+ const timeWaiting = waitMs - timeSinceLastCall;
63
68
  return maxing ? Math.min(timeWaiting, (maxWait ?? 0) - timeSinceLastInvoke) : timeWaiting;
64
69
  }
65
70
  function shouldInvoke(time) {
66
71
  const timeSinceLastCall = time - (lastCallTime ?? 0);
67
72
  const timeSinceLastInvoke = time - lastInvokeTime;
68
- return lastCallTime === void 0 || timeSinceLastCall >= wait || timeSinceLastCall < 0 || maxing && timeSinceLastInvoke >= (maxWait ?? 0);
73
+ return lastCallTime === void 0 || timeSinceLastCall >= waitMs || timeSinceLastCall < 0 || maxing && timeSinceLastInvoke >= (maxWait ?? 0);
69
74
  }
70
75
  function timerExpired() {
71
76
  const time = Date.now();
@@ -92,6 +97,30 @@ function debounce(func, wait, options) {
92
97
  function flush() {
93
98
  return timerId === void 0 ? result : trailingEdge(Date.now());
94
99
  }
100
+ function pending() {
101
+ return timerId !== void 0;
102
+ }
103
+ function updateCb(callback) {
104
+ currentCallback = callback;
105
+ }
106
+ function updateParams(newWait, newOptions) {
107
+ waitMs = newWait;
108
+ if (newOptions !== void 0) {
109
+ currentOptions = newOptions;
110
+ }
111
+ applyOptions();
112
+ if (timerId !== void 0) {
113
+ const time = Date.now();
114
+ const shouldRun = shouldInvoke(time);
115
+ clearTimeout(timerId);
116
+ if (shouldRun) {
117
+ timerId = setTimeout(timerExpired, 0);
118
+ } else {
119
+ const delay = remainingWait(time);
120
+ timerId = setTimeout(timerExpired, delay > 0 ? delay : 0);
121
+ }
122
+ }
123
+ }
95
124
  function debounced() {
96
125
  const time = Date.now();
97
126
  const isInvoking = shouldInvoke(time);
@@ -104,17 +133,20 @@ function debounce(func, wait, options) {
104
133
  }
105
134
  if (maxing) {
106
135
  clearTimeout(timerId);
107
- timerId = setTimeout(timerExpired, wait);
136
+ timerId = setTimeout(timerExpired, waitMs);
108
137
  return invokeFunc(lastCallTime);
109
138
  }
110
139
  }
111
140
  if (timerId === void 0) {
112
- timerId = setTimeout(timerExpired, wait);
141
+ timerId = setTimeout(timerExpired, waitMs);
113
142
  }
114
143
  return result;
115
144
  }
116
145
  debounced.cancel = cancel;
117
146
  debounced.flush = flush;
147
+ debounced.pending = pending;
148
+ debounced.updateCb = updateCb;
149
+ debounced.updateParams = updateParams;
118
150
  return debounced;
119
151
  }
120
152
 
package/dist/throttle.js CHANGED
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  debounce
3
- } from "./chunk-NW5H5EW7.js";
3
+ } from "./chunk-CCUPDGSZ.js";
4
4
  import {
5
5
  EnhancedMap
6
6
  } from "./chunk-7CQPOM5I.js";
package/dist/time.js CHANGED
@@ -15,8 +15,8 @@ import {
15
15
  getUnixSeconds,
16
16
  msToTimeString,
17
17
  parseTimeStringToMs
18
- } from "./chunk-5MNYPLZI.js";
19
- import "./chunk-HTCYUMDR.js";
18
+ } from "./chunk-6FBIEPWU.js";
19
+ import "./chunk-DBOWTYR4.js";
20
20
  import "./chunk-II4R3VVX.js";
21
21
  export {
22
22
  DAY_AS_MS,
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@ls-stack/utils",
3
3
  "description": "Universal TypeScript utilities for browser and Node.js",
4
- "version": "3.56.0",
4
+ "version": "3.58.0",
5
5
  "license": "MIT",
6
6
  "files": [
7
7
  "dist",
@@ -112,6 +112,10 @@
112
112
  "import": "./dist/interpolate.js",
113
113
  "require": "./dist/interpolate.cjs"
114
114
  },
115
+ "./iteratorUtils": {
116
+ "import": "./dist/iteratorUtils.js",
117
+ "require": "./dist/iteratorUtils.cjs"
118
+ },
115
119
  "./keepPrevIfUnchanged": {
116
120
  "import": "./dist/keepPrevIfUnchanged.js",
117
121
  "require": "./dist/keepPrevIfUnchanged.cjs"
@@ -1,27 +0,0 @@
1
- // src/mathUtils.ts
2
- function clampMax(value, max) {
3
- return value > max ? max : value;
4
- }
5
- function clampMin(value, min) {
6
- return value < min ? min : value;
7
- }
8
- function clampRange(num, v1, v2) {
9
- if (v2 > v1) {
10
- return clamp(num, v1, v2);
11
- }
12
- return clamp(num, v2, v1);
13
- }
14
- function clamp(num, min, max) {
15
- return num > max ? max : num < min ? min : num;
16
- }
17
- function fixFloatingPointNumber(value) {
18
- return Number(value.toPrecision(15));
19
- }
20
-
21
- export {
22
- clampMax,
23
- clampMin,
24
- clampRange,
25
- clamp,
26
- fixFloatingPointNumber
27
- };