@ls-stack/utils 1.13.2 → 2.0.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.
Files changed (140) hide show
  1. package/dist/arrayUtils.cjs +91 -0
  2. package/dist/arrayUtils.d.cts +51 -0
  3. package/dist/arrayUtils.js +1 -2
  4. package/dist/assertions.cjs +99 -0
  5. package/dist/assertions.d.cts +17 -0
  6. package/dist/assertions.js +1 -2
  7. package/dist/castValues.cjs +41 -0
  8. package/dist/castValues.d.cts +4 -0
  9. package/dist/castValues.js +0 -1
  10. package/dist/chunk-3PXKYWJF.js +148 -0
  11. package/dist/{chunk-FYMTZQ42.js → chunk-4UGSP3L3.js} +0 -1
  12. package/dist/{chunk-HLFWWIDK.js → chunk-5DZT3Z5Z.js} +0 -1
  13. package/dist/{chunk-W7X6NSGR.js → chunk-AZBBTE33.js} +0 -1
  14. package/dist/{chunk-MMKMF4GG.js → chunk-IATIXMCE.js} +0 -1
  15. package/dist/{chunk-M74KKYE4.js → chunk-KCOXGSRA.js} +0 -1
  16. package/dist/{chunk-NKCC3375.js → chunk-NWXBMMHO.js} +0 -1
  17. package/dist/{chunk-SNAAKCTH.js → chunk-RVVH3MDA.js} +0 -1
  18. package/dist/{chunk-4QK76IRX.js → chunk-T5WDDPFI.js} +1 -6
  19. package/dist/{chunk-GLZ5MZC5.js → chunk-V2L472LS.js} +0 -30
  20. package/dist/consoleFmt.cjs +84 -0
  21. package/dist/consoleFmt.d.cts +48 -0
  22. package/dist/consoleFmt.js +0 -1
  23. package/dist/conversions.cjs +44 -0
  24. package/dist/conversions.d.cts +3 -0
  25. package/dist/conversions.js +1 -2
  26. package/dist/createThrottleController.cjs +183 -0
  27. package/dist/createThrottleController.d.cts +16 -0
  28. package/dist/createThrottleController.js +2 -3
  29. package/dist/debounce.cjs +125 -0
  30. package/dist/debounce.d.cts +45 -0
  31. package/dist/debounce.js +0 -1
  32. package/dist/dedent.cjs +57 -0
  33. package/dist/dedent.d.cts +4 -0
  34. package/dist/dedent.js +0 -1
  35. package/dist/deepEqual.cjs +88 -0
  36. package/dist/deepEqual.d.cts +4 -0
  37. package/dist/deepEqual.js +1 -2
  38. package/dist/enhancedMap.cjs +128 -0
  39. package/dist/enhancedMap.d.cts +20 -0
  40. package/dist/enhancedMap.d.ts +0 -2
  41. package/dist/enhancedMap.js +2 -3
  42. package/dist/exhaustiveMatch.cjs +55 -0
  43. package/dist/exhaustiveMatch.d.cts +6 -0
  44. package/dist/exhaustiveMatch.js +0 -1
  45. package/dist/interpolate.cjs +88 -0
  46. package/dist/interpolate.d.cts +11 -0
  47. package/dist/interpolate.js +2 -3
  48. package/dist/levenshtein.cjs +180 -0
  49. package/dist/levenshtein.d.cts +5 -0
  50. package/dist/levenshtein.js +0 -1
  51. package/dist/main.cjs +4 -0
  52. package/dist/main.d.cts +2 -0
  53. package/dist/main.d.ts +1 -1
  54. package/dist/main.js +0 -1
  55. package/dist/mathUtils.cjs +50 -0
  56. package/dist/mathUtils.d.cts +6 -0
  57. package/dist/mathUtils.js +1 -2
  58. package/dist/objUtils.cjs +67 -0
  59. package/dist/objUtils.d.cts +7 -0
  60. package/dist/objUtils.js +1 -2
  61. package/dist/parallelAsyncCalls.cjs +266 -0
  62. package/dist/{parallelAsyncResultCalls.d.ts → parallelAsyncCalls.d.cts} +7 -7
  63. package/dist/parallelAsyncCalls.d.ts +76 -0
  64. package/dist/{parallelAsyncResultCalls.js → parallelAsyncCalls.js} +7 -9
  65. package/dist/promiseUtils.cjs +38 -0
  66. package/dist/promiseUtils.d.cts +8 -0
  67. package/dist/promiseUtils.js +0 -1
  68. package/dist/rsResult.cjs +180 -0
  69. package/dist/rsResult.d.cts +83 -0
  70. package/dist/rsResult.d.ts +34 -69
  71. package/dist/rsResult.js +6 -10
  72. package/dist/runShellCmd.cjs +127 -0
  73. package/dist/runShellCmd.d.cts +23 -0
  74. package/dist/runShellCmd.d.ts +2 -1
  75. package/dist/runShellCmd.js +9 -4
  76. package/dist/shallowEqual.cjs +88 -0
  77. package/dist/shallowEqual.d.cts +4 -0
  78. package/dist/shallowEqual.js +0 -1
  79. package/dist/sleep.cjs +32 -0
  80. package/dist/sleep.d.cts +3 -0
  81. package/dist/sleep.js +1 -2
  82. package/dist/stringUtils.cjs +66 -0
  83. package/dist/stringUtils.d.cts +16 -0
  84. package/dist/stringUtils.d.ts +1 -3
  85. package/dist/stringUtils.js +1 -4
  86. package/dist/testUtils.cjs +357 -0
  87. package/dist/testUtils.d.cts +38 -0
  88. package/dist/testUtils.js +5 -6
  89. package/dist/typingFnUtils.cjs +55 -0
  90. package/dist/typingFnUtils.d.cts +15 -0
  91. package/dist/typingFnUtils.js +0 -1
  92. package/dist/typingTestUtils.cjs +43 -0
  93. package/dist/typingTestUtils.d.cts +12 -0
  94. package/dist/typingTestUtils.js +0 -1
  95. package/dist/typingUtils.cjs +18 -0
  96. package/dist/typingUtils.d.cts +11 -0
  97. package/dist/typingUtils.js +0 -1
  98. package/dist/yamlStringify.cjs +346 -0
  99. package/dist/yamlStringify.d.cts +8 -0
  100. package/dist/yamlStringify.js +3 -4
  101. package/package.json +64 -34
  102. package/dist/arrayUtils.js.map +0 -1
  103. package/dist/assertions.js.map +0 -1
  104. package/dist/castValues.js.map +0 -1
  105. package/dist/chunk-4QK76IRX.js.map +0 -1
  106. package/dist/chunk-FYMTZQ42.js.map +0 -1
  107. package/dist/chunk-GLZ5MZC5.js.map +0 -1
  108. package/dist/chunk-HLFWWIDK.js.map +0 -1
  109. package/dist/chunk-I7ZDKDUM.js +0 -217
  110. package/dist/chunk-I7ZDKDUM.js.map +0 -1
  111. package/dist/chunk-M74KKYE4.js.map +0 -1
  112. package/dist/chunk-MMKMF4GG.js.map +0 -1
  113. package/dist/chunk-NKCC3375.js.map +0 -1
  114. package/dist/chunk-SNAAKCTH.js.map +0 -1
  115. package/dist/chunk-W7X6NSGR.js.map +0 -1
  116. package/dist/consoleFmt.js.map +0 -1
  117. package/dist/conversions.js.map +0 -1
  118. package/dist/createThrottleController.js.map +0 -1
  119. package/dist/debounce.js.map +0 -1
  120. package/dist/dedent.js.map +0 -1
  121. package/dist/deepEqual.js.map +0 -1
  122. package/dist/enhancedMap.js.map +0 -1
  123. package/dist/exhaustiveMatch.js.map +0 -1
  124. package/dist/interpolate.js.map +0 -1
  125. package/dist/levenshtein.js.map +0 -1
  126. package/dist/main.js.map +0 -1
  127. package/dist/mathUtils.js.map +0 -1
  128. package/dist/objUtils.js.map +0 -1
  129. package/dist/parallelAsyncResultCalls.js.map +0 -1
  130. package/dist/promiseUtils.js.map +0 -1
  131. package/dist/rsResult.js.map +0 -1
  132. package/dist/runShellCmd.js.map +0 -1
  133. package/dist/shallowEqual.js.map +0 -1
  134. package/dist/sleep.js.map +0 -1
  135. package/dist/stringUtils.js.map +0 -1
  136. package/dist/testUtils.js.map +0 -1
  137. package/dist/typingFnUtils.js.map +0 -1
  138. package/dist/typingTestUtils.js.map +0 -1
  139. package/dist/typingUtils.js.map +0 -1
  140. package/dist/yamlStringify.js.map +0 -1
@@ -0,0 +1,48 @@
1
+ declare const colorToCodeASCII: {
2
+ red: string;
3
+ green: string;
4
+ yellow: string;
5
+ blue: string;
6
+ magenta: string;
7
+ cyan: string;
8
+ white: string;
9
+ black: string;
10
+ gray: string;
11
+ brightRed: string;
12
+ brightGreen: string;
13
+ brightYellow: string;
14
+ brightBlue: string;
15
+ brightMagenta: string;
16
+ brightCyan: string;
17
+ brightWhite: string;
18
+ };
19
+ declare function consoleColors(color: keyof typeof colorToCodeASCII, text: string): string;
20
+ declare function bold(text: string): string;
21
+ declare function underline(text: string): string;
22
+ declare const bgColorToCodeASCII: {
23
+ red: string;
24
+ green: string;
25
+ yellow: string;
26
+ blue: string;
27
+ magenta: string;
28
+ cyan: string;
29
+ white: string;
30
+ black: string;
31
+ gray: string;
32
+ brightRed: string;
33
+ brightGreen: string;
34
+ brightYellow: string;
35
+ brightBlue: string;
36
+ brightMagenta: string;
37
+ brightCyan: string;
38
+ brightWhite: string;
39
+ };
40
+ declare function bgColor(color: keyof typeof bgColorToCodeASCII, text: string): string;
41
+ declare const consoleFmt: {
42
+ color: typeof consoleColors;
43
+ bold: typeof bold;
44
+ underline: typeof underline;
45
+ bgColor: typeof bgColor;
46
+ };
47
+
48
+ export { consoleFmt };
@@ -57,4 +57,3 @@ var consoleFmt = {
57
57
  export {
58
58
  consoleFmt
59
59
  };
60
- //# sourceMappingURL=consoleFmt.js.map
@@ -0,0 +1,44 @@
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/conversions.ts
21
+ var conversions_exports = {};
22
+ __export(conversions_exports, {
23
+ bytesToHumanReadable: () => bytesToHumanReadable
24
+ });
25
+ module.exports = __toCommonJS(conversions_exports);
26
+ function bytesToHumanReadable(bytes) {
27
+ if (bytes < 1024) {
28
+ return `${bytes} B`;
29
+ }
30
+ const kb = bytes / 1024;
31
+ if (kb < 1024) {
32
+ return `${kb.toFixed(2)} KB`;
33
+ }
34
+ const mb = kb / 1024;
35
+ if (mb < 1024) {
36
+ return `${mb.toFixed(2)} MB`;
37
+ }
38
+ const gb = mb / 1024;
39
+ return `${gb.toFixed(2)} GB`;
40
+ }
41
+ // Annotate the CommonJS export names for ESM import in node:
42
+ 0 && (module.exports = {
43
+ bytesToHumanReadable
44
+ });
@@ -0,0 +1,3 @@
1
+ declare function bytesToHumanReadable(bytes: number): string;
2
+
3
+ export { bytesToHumanReadable };
@@ -1,7 +1,6 @@
1
1
  import {
2
2
  bytesToHumanReadable
3
- } from "./chunk-MMKMF4GG.js";
3
+ } from "./chunk-IATIXMCE.js";
4
4
  export {
5
5
  bytesToHumanReadable
6
6
  };
7
- //# sourceMappingURL=conversions.js.map
@@ -0,0 +1,183 @@
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/createThrottleController.ts
21
+ var createThrottleController_exports = {};
22
+ __export(createThrottleController_exports, {
23
+ createThrottleController: () => createThrottleController
24
+ });
25
+ module.exports = __toCommonJS(createThrottleController_exports);
26
+
27
+ // src/assertions.ts
28
+ function isFunction(value) {
29
+ return typeof value === "function";
30
+ }
31
+
32
+ // src/enhancedMap.ts
33
+ var enhancedMapReject = Symbol();
34
+ var EnhancedMap = class _EnhancedMap extends Map {
35
+ find(predicate) {
36
+ for (const [key, value] of this) {
37
+ if (predicate(value, key)) {
38
+ return { key, value };
39
+ }
40
+ }
41
+ return void 0;
42
+ }
43
+ setMultiple(...values) {
44
+ if (Array.isArray(values[0])) {
45
+ for (const [key, value] of values) {
46
+ this.set(key, value);
47
+ }
48
+ } else {
49
+ for (const [key, value] of Object.entries(values[0])) {
50
+ this.set(key, value);
51
+ }
52
+ }
53
+ return this;
54
+ }
55
+ getOrThrow(key) {
56
+ const value = this.get(key);
57
+ if (value === void 0) {
58
+ throw new Error(`Key ${key} not found in EnhancedMap`);
59
+ }
60
+ return value;
61
+ }
62
+ getOrInsert(key, fallback) {
63
+ if (!this.has(key)) {
64
+ this.set(key, fallback());
65
+ }
66
+ return this.getOrThrow(key);
67
+ }
68
+ toFilteredValues(predicate) {
69
+ const values = [];
70
+ for (const [key, value] of this) {
71
+ if (predicate(value, key)) {
72
+ values.push(value);
73
+ }
74
+ }
75
+ return values;
76
+ }
77
+ toMap(mapFunction) {
78
+ const values = [];
79
+ for (const [key, value] of this) {
80
+ const result = mapFunction(value, key, enhancedMapReject);
81
+ if (result !== enhancedMapReject) {
82
+ values.push(result);
83
+ }
84
+ }
85
+ return values;
86
+ }
87
+ toObjMap(mapFunction) {
88
+ const values = {};
89
+ for (const [key, value] of this) {
90
+ const result = mapFunction(value, key);
91
+ if (result) {
92
+ values[result[0]] = result[1];
93
+ }
94
+ }
95
+ return values;
96
+ }
97
+ toValues() {
98
+ return [...this.values()];
99
+ }
100
+ toKeys() {
101
+ return [...this.keys()];
102
+ }
103
+ static from(array, mapFunction) {
104
+ const map = new _EnhancedMap();
105
+ if (!array) return map;
106
+ const isFn = isFunction(mapFunction);
107
+ for (const item of array) {
108
+ if (isFn) {
109
+ const result = mapFunction(item);
110
+ if (result) {
111
+ map.set(result[0], result[1]);
112
+ }
113
+ } else {
114
+ const key = item[mapFunction];
115
+ if (key !== void 0) {
116
+ map.set(key, item);
117
+ }
118
+ }
119
+ }
120
+ return map;
121
+ }
122
+ };
123
+
124
+ // src/createThrottleController.ts
125
+ function createThrottleController({
126
+ maxCalls,
127
+ per,
128
+ cleanupCheckSecsInterval = 60 * 30
129
+ }) {
130
+ let msInterval = 0;
131
+ if (per.ms) {
132
+ msInterval = per.ms;
133
+ } else if (per.seconds) {
134
+ msInterval = per.seconds * 1e3;
135
+ } else if (per.minutes) {
136
+ msInterval = per.minutes * 1e3 * 60;
137
+ } else if (per.hours) {
138
+ msInterval = per.hours * 1e3 * 60 * 60;
139
+ }
140
+ if (msInterval === 0) {
141
+ throw new Error("Invalid interval");
142
+ }
143
+ let lastCleanupCheck = Date.now();
144
+ const windows = new EnhancedMap();
145
+ function cleanup(checkTime) {
146
+ const shouldCleanup = checkTime - lastCleanupCheck > cleanupCheckSecsInterval * 1e3;
147
+ if (!shouldCleanup) return;
148
+ setTimeout(() => {
149
+ const now = Date.now();
150
+ lastCleanupCheck = now;
151
+ for (const [key, value] of windows) {
152
+ if (now - value.windowStartTime > msInterval) {
153
+ windows.delete(key);
154
+ }
155
+ }
156
+ }, 2);
157
+ }
158
+ return {
159
+ shouldSkip(callId = "") {
160
+ const now = Date.now();
161
+ const serializedCallId = String(callId);
162
+ const window = windows.getOrInsert(serializedCallId, () => ({
163
+ windowStartTime: now,
164
+ calls: 0
165
+ }));
166
+ if (now - window.windowStartTime > msInterval) {
167
+ window.windowStartTime = now;
168
+ window.calls = 0;
169
+ }
170
+ window.calls++;
171
+ cleanup(now);
172
+ if (window.calls > maxCalls) {
173
+ return true;
174
+ }
175
+ return false;
176
+ },
177
+ _currentWindows: windows
178
+ };
179
+ }
180
+ // Annotate the CommonJS export names for ESM import in node:
181
+ 0 && (module.exports = {
182
+ createThrottleController
183
+ });
@@ -0,0 +1,16 @@
1
+ type Options = {
2
+ maxCalls: number;
3
+ per: {
4
+ ms?: number;
5
+ seconds?: number;
6
+ minutes?: number;
7
+ hours?: number;
8
+ };
9
+ cleanupCheckSecsInterval?: number;
10
+ };
11
+ type ThrottleController = {
12
+ shouldSkip: (callId?: string | number | (string | number)[]) => boolean;
13
+ };
14
+ declare function createThrottleController({ maxCalls, per, cleanupCheckSecsInterval, }: Options): ThrottleController;
15
+
16
+ export { createThrottleController };
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  EnhancedMap
3
- } from "./chunk-4QK76IRX.js";
4
- import "./chunk-FYMTZQ42.js";
3
+ } from "./chunk-T5WDDPFI.js";
4
+ import "./chunk-4UGSP3L3.js";
5
5
 
6
6
  // src/createThrottleController.ts
7
7
  function createThrottleController({
@@ -62,4 +62,3 @@ function createThrottleController({
62
62
  export {
63
63
  createThrottleController
64
64
  };
65
- //# sourceMappingURL=createThrottleController.js.map
@@ -0,0 +1,125 @@
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/debounce.ts
21
+ var debounce_exports = {};
22
+ __export(debounce_exports, {
23
+ debounce: () => debounce,
24
+ isDebouncedFn: () => isDebouncedFn
25
+ });
26
+ module.exports = __toCommonJS(debounce_exports);
27
+ function debounce(func, wait, options) {
28
+ let lastArgs;
29
+ let lastThis;
30
+ let maxWait;
31
+ let result;
32
+ let timerId;
33
+ let lastCallTime;
34
+ let lastInvokeTime = 0;
35
+ let leading = false;
36
+ let maxing = false;
37
+ let trailing = true;
38
+ if (options) {
39
+ leading = !!options.leading;
40
+ maxing = "maxWait" in options;
41
+ maxWait = maxing ? Math.max(options.maxWait || 0, wait) : maxWait;
42
+ trailing = "trailing" in options ? !!options.trailing : trailing;
43
+ }
44
+ function invokeFunc(time) {
45
+ const args = lastArgs;
46
+ const thisArg = lastThis;
47
+ lastArgs = lastThis = void 0;
48
+ lastInvokeTime = time;
49
+ result = func.apply(thisArg, args);
50
+ return result;
51
+ }
52
+ function leadingEdge(time) {
53
+ lastInvokeTime = time;
54
+ timerId = setTimeout(timerExpired, wait);
55
+ return leading ? invokeFunc(time) : result;
56
+ }
57
+ function remainingWait(time) {
58
+ const timeSinceLastCall = time - (lastCallTime ?? 0);
59
+ const timeSinceLastInvoke = time - lastInvokeTime;
60
+ const timeWaiting = wait - timeSinceLastCall;
61
+ return maxing ? Math.min(timeWaiting, (maxWait ?? 0) - timeSinceLastInvoke) : timeWaiting;
62
+ }
63
+ function shouldInvoke(time) {
64
+ const timeSinceLastCall = time - (lastCallTime ?? 0);
65
+ const timeSinceLastInvoke = time - lastInvokeTime;
66
+ return lastCallTime === void 0 || timeSinceLastCall >= wait || timeSinceLastCall < 0 || maxing && timeSinceLastInvoke >= (maxWait ?? 0);
67
+ }
68
+ function timerExpired() {
69
+ const time = Date.now();
70
+ if (shouldInvoke(time)) {
71
+ return trailingEdge(time);
72
+ }
73
+ timerId = setTimeout(timerExpired, remainingWait(time));
74
+ }
75
+ function trailingEdge(time) {
76
+ timerId = void 0;
77
+ if (trailing && lastArgs) {
78
+ return invokeFunc(time);
79
+ }
80
+ lastArgs = lastThis = void 0;
81
+ return result;
82
+ }
83
+ function cancel() {
84
+ if (timerId !== void 0) {
85
+ clearTimeout(timerId);
86
+ }
87
+ lastInvokeTime = 0;
88
+ lastArgs = lastCallTime = lastThis = timerId = void 0;
89
+ }
90
+ function flush() {
91
+ return timerId === void 0 ? result : trailingEdge(Date.now());
92
+ }
93
+ function debounced() {
94
+ const time = Date.now();
95
+ const isInvoking = shouldInvoke(time);
96
+ lastArgs = arguments;
97
+ lastThis = this;
98
+ lastCallTime = time;
99
+ if (isInvoking) {
100
+ if (timerId === void 0) {
101
+ return leadingEdge(lastCallTime);
102
+ }
103
+ if (maxing) {
104
+ clearTimeout(timerId);
105
+ timerId = setTimeout(timerExpired, wait);
106
+ return invokeFunc(lastCallTime);
107
+ }
108
+ }
109
+ if (timerId === void 0) {
110
+ timerId = setTimeout(timerExpired, wait);
111
+ }
112
+ return result;
113
+ }
114
+ debounced.cancel = cancel;
115
+ debounced.flush = flush;
116
+ return debounced;
117
+ }
118
+ function isDebouncedFn(fn) {
119
+ return typeof fn === "function" && "cancel" in fn && "flush" in fn;
120
+ }
121
+ // Annotate the CommonJS export names for ESM import in node:
122
+ 0 && (module.exports = {
123
+ debounce,
124
+ isDebouncedFn
125
+ });
@@ -0,0 +1,45 @@
1
+ type DebounceOptions = {
2
+ /**
3
+ * @see _.leading
4
+ */
5
+ leading?: boolean;
6
+ /**
7
+ * @see _.maxWait
8
+ */
9
+ maxWait?: number;
10
+ /**
11
+ * @see _.trailing
12
+ */
13
+ trailing?: boolean;
14
+ };
15
+ interface DebouncedFunc<T extends (...args: any[]) => void> {
16
+ /**
17
+ * Call the original function, but applying the debounce rules.
18
+ *
19
+ * If the debounced function can be run immediately, this calls it and returns its return
20
+ * value.
21
+ *
22
+ * Otherwise, it returns the return value of the last invocation, or undefined if the debounced
23
+ * function was not invoked yet.
24
+ */
25
+ (...args: Parameters<T>): ReturnType<T> | undefined;
26
+ /**
27
+ * Throw away any pending invocation of the debounced function.
28
+ */
29
+ cancel: () => void;
30
+ /**
31
+ * If there is a pending invocation of the debounced function, invoke it immediately and return
32
+ * its return value.
33
+ *
34
+ * Otherwise, return the value from the last invocation, or undefined if the debounced function
35
+ * was never invoked.
36
+ */
37
+ flush: () => ReturnType<T> | undefined;
38
+ }
39
+ declare function debounce<T extends (...args: any[]) => void>(func: T, wait: number, options?: DebounceOptions): DebouncedFunc<T>;
40
+ declare function isDebouncedFn<T extends (...args: any[]) => void>(fn: T): fn is T & {
41
+ cancel: () => void;
42
+ flush: () => ReturnType<T> | undefined;
43
+ };
44
+
45
+ export { type DebounceOptions, type DebouncedFunc, debounce, isDebouncedFn };
package/dist/debounce.js CHANGED
@@ -97,4 +97,3 @@ export {
97
97
  debounce,
98
98
  isDebouncedFn
99
99
  };
100
- //# sourceMappingURL=debounce.js.map
@@ -0,0 +1,57 @@
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/dedent.ts
21
+ var dedent_exports = {};
22
+ __export(dedent_exports, {
23
+ dedent: () => dedent
24
+ });
25
+ module.exports = __toCommonJS(dedent_exports);
26
+ function dedent(strings, ...values) {
27
+ const raw = typeof strings === "string" ? [strings] : strings.raw;
28
+ let result = "";
29
+ for (let i = 0; i < raw.length; i++) {
30
+ result += raw[i].replace(/\\\n[ \t]*/g, "").replace(/\\`/g, "`");
31
+ if (i < values.length) {
32
+ result += values[i];
33
+ }
34
+ }
35
+ const lines = result.split("\n");
36
+ let mindent = null;
37
+ lines.forEach((l) => {
38
+ const m = l.match(/^(\s+)\S+/);
39
+ if (m) {
40
+ const indent = m[1].length;
41
+ if (!mindent) {
42
+ mindent = indent;
43
+ } else {
44
+ mindent = Math.min(mindent, indent);
45
+ }
46
+ }
47
+ });
48
+ if (mindent !== null) {
49
+ const m = mindent;
50
+ result = lines.map((l) => l.startsWith(" ") ? l.slice(m) : l).join("\n");
51
+ }
52
+ return result.trim().replace(/\\n/g, "\n");
53
+ }
54
+ // Annotate the CommonJS export names for ESM import in node:
55
+ 0 && (module.exports = {
56
+ dedent
57
+ });
@@ -0,0 +1,4 @@
1
+ declare function dedent(strings: TemplateStringsArray, ...values: string[]): string;
2
+ declare function dedent(strings: string): string;
3
+
4
+ export { dedent };
package/dist/dedent.js CHANGED
@@ -30,4 +30,3 @@ function dedent(strings, ...values) {
30
30
  export {
31
31
  dedent
32
32
  };
33
- //# sourceMappingURL=dedent.js.map
@@ -0,0 +1,88 @@
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/deepEqual.ts
21
+ var deepEqual_exports = {};
22
+ __export(deepEqual_exports, {
23
+ deepEqual: () => deepEqual
24
+ });
25
+ module.exports = __toCommonJS(deepEqual_exports);
26
+ var has = Object.prototype.hasOwnProperty;
27
+ function find(iter, tar, key) {
28
+ for (key of iter.keys()) {
29
+ if (deepEqual(key, tar)) return key;
30
+ }
31
+ }
32
+ function deepEqual(foo, bar) {
33
+ let ctor, len, tmp;
34
+ if (foo === bar) return true;
35
+ if (foo && bar && (ctor = foo.constructor) === bar.constructor) {
36
+ if (ctor === Date) return deepEqual(foo.getTime(), bar.getTime());
37
+ if (ctor === RegExp) return foo.toString() === bar.toString();
38
+ if (ctor === Array) {
39
+ if ((len = foo.length) === bar.length) {
40
+ while (len-- && deepEqual(foo[len], bar[len])) ;
41
+ }
42
+ return len === -1;
43
+ }
44
+ if (ctor === Set) {
45
+ if (foo.size !== bar.size) {
46
+ return false;
47
+ }
48
+ for (len of foo) {
49
+ tmp = len;
50
+ if (tmp && typeof tmp === "object") {
51
+ tmp = find(bar, tmp);
52
+ if (!tmp) return false;
53
+ }
54
+ if (!bar.has(tmp)) return false;
55
+ }
56
+ return true;
57
+ }
58
+ if (ctor === Map) {
59
+ if (foo.size !== bar.size) {
60
+ return false;
61
+ }
62
+ for (len of foo) {
63
+ tmp = len[0];
64
+ if (tmp && typeof tmp === "object") {
65
+ tmp = find(bar, tmp);
66
+ if (!tmp) return false;
67
+ }
68
+ if (!deepEqual(len[1], bar.get(tmp))) {
69
+ return false;
70
+ }
71
+ }
72
+ return true;
73
+ }
74
+ if (!ctor || typeof foo === "object") {
75
+ len = 0;
76
+ for (ctor in foo) {
77
+ if (has.call(foo, ctor) && ++len && !has.call(bar, ctor)) return false;
78
+ if (!(ctor in bar) || !deepEqual(foo[ctor], bar[ctor])) return false;
79
+ }
80
+ return Object.keys(bar).length === len;
81
+ }
82
+ }
83
+ return foo !== foo && bar !== bar;
84
+ }
85
+ // Annotate the CommonJS export names for ESM import in node:
86
+ 0 && (module.exports = {
87
+ deepEqual
88
+ });
@@ -0,0 +1,4 @@
1
+ /** forked from https://github.com/lukeed/dequal to consider invalid dates as equal */
2
+ declare function deepEqual(foo: any, bar: any): boolean;
3
+
4
+ export { deepEqual };
package/dist/deepEqual.js CHANGED
@@ -1,7 +1,6 @@
1
1
  import {
2
2
  deepEqual
3
- } from "./chunk-M74KKYE4.js";
3
+ } from "./chunk-KCOXGSRA.js";
4
4
  export {
5
5
  deepEqual
6
6
  };
7
- //# sourceMappingURL=deepEqual.js.map