@ls-stack/utils 3.40.0 → 3.41.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 (158) hide show
  1. package/dist/arrayUtils.d.cts +70 -57
  2. package/dist/arrayUtils.d.ts +70 -57
  3. package/dist/assertions.d.cts +128 -117
  4. package/dist/assertions.d.ts +128 -117
  5. package/dist/asyncQueue.cjs +117 -112
  6. package/dist/asyncQueue.d.cts +217 -215
  7. package/dist/asyncQueue.d.ts +217 -215
  8. package/dist/asyncQueue.js +117 -112
  9. package/dist/awaitDebounce.d.cts +26 -23
  10. package/dist/awaitDebounce.d.ts +26 -23
  11. package/dist/cache.cjs +2 -1
  12. package/dist/cache.d.cts +15 -9
  13. package/dist/cache.d.ts +15 -9
  14. package/dist/cache.js +2 -1
  15. package/dist/{chunk-GHAQOUA6.js → chunk-23KPGKDT.js} +22 -1
  16. package/dist/{chunk-ADM37GSC.js → chunk-7L4KCZJJ.js} +12 -10
  17. package/dist/{chunk-KW55OTUG.js → chunk-B3KFV2MH.js} +2 -2
  18. package/dist/chunk-DTE2QMWE.js +48 -0
  19. package/dist/concurrentCalls.d.cts +8 -4
  20. package/dist/concurrentCalls.d.ts +8 -4
  21. package/dist/concurrentCalls.js +1 -1
  22. package/dist/debounce.d.cts +12 -20
  23. package/dist/debounce.d.ts +12 -20
  24. package/dist/dedent.d.cts +31 -31
  25. package/dist/dedent.d.ts +31 -31
  26. package/dist/deepEqual.d.cts +10 -9
  27. package/dist/deepEqual.d.ts +10 -9
  28. package/dist/filterObjectOrArrayKeys.d.cts +44 -19
  29. package/dist/filterObjectOrArrayKeys.d.ts +44 -19
  30. package/dist/getAutoIncrementId.d.cts +25 -23
  31. package/dist/getAutoIncrementId.d.ts +25 -23
  32. package/dist/getCompositeKey.d.cts +2 -1
  33. package/dist/getCompositeKey.d.ts +2 -1
  34. package/dist/getValueStableKey.d.cts +4 -3
  35. package/dist/getValueStableKey.d.ts +4 -3
  36. package/dist/mutationUtils.d.cts +2 -2
  37. package/dist/mutationUtils.d.ts +2 -2
  38. package/dist/objUtils.cjs +51 -2
  39. package/dist/objUtils.d.cts +8 -3
  40. package/dist/objUtils.d.ts +8 -3
  41. package/dist/objUtils.js +11 -3
  42. package/dist/parallelAsyncCalls.cjs +2 -1
  43. package/dist/parallelAsyncCalls.d.cts +5 -4
  44. package/dist/parallelAsyncCalls.d.ts +5 -4
  45. package/dist/parallelAsyncCalls.js +2 -1
  46. package/dist/retryOnError.d.cts +23 -20
  47. package/dist/retryOnError.d.ts +23 -20
  48. package/dist/runShellCmd.d.cts +40 -40
  49. package/dist/runShellCmd.d.ts +40 -40
  50. package/dist/safeJson.d.cts +6 -2
  51. package/dist/safeJson.d.ts +6 -2
  52. package/dist/saferTyping.d.cts +21 -14
  53. package/dist/saferTyping.d.ts +21 -14
  54. package/dist/shallowEqual.d.cts +1 -1
  55. package/dist/shallowEqual.d.ts +1 -1
  56. package/dist/stringUtils.cjs +2 -2
  57. package/dist/stringUtils.d.cts +6 -7
  58. package/dist/stringUtils.d.ts +6 -7
  59. package/dist/stringUtils.js +1 -1
  60. package/dist/testUtils.cjs +11 -9
  61. package/dist/testUtils.d.cts +32 -14
  62. package/dist/testUtils.d.ts +32 -14
  63. package/dist/testUtils.js +4 -3
  64. package/dist/throttle.d.cts +57 -48
  65. package/dist/throttle.d.ts +57 -48
  66. package/dist/timers.d.cts +68 -63
  67. package/dist/timers.d.ts +68 -63
  68. package/dist/tsResult.d.cts +7 -6
  69. package/dist/tsResult.d.ts +7 -6
  70. package/dist/typeGuards.d.cts +65 -64
  71. package/dist/typeGuards.d.ts +65 -64
  72. package/dist/typeUtils.d.cts +18 -4
  73. package/dist/typeUtils.d.ts +18 -4
  74. package/dist/typedStrings.d.cts +68 -57
  75. package/dist/typedStrings.d.ts +68 -57
  76. package/dist/typingFnUtils.d.cts +12 -6
  77. package/dist/typingFnUtils.d.ts +12 -6
  78. package/dist/typingFnUtils.js +12 -35
  79. package/dist/typingTestUtils.cjs +7 -1
  80. package/dist/typingTestUtils.d.cts +52 -11
  81. package/dist/typingTestUtils.d.ts +52 -11
  82. package/dist/typingTestUtils.js +7 -1
  83. package/dist/typingUtils.d.cts +4 -1
  84. package/dist/typingUtils.d.ts +4 -1
  85. package/dist/yamlStringify.cjs +11 -9
  86. package/dist/yamlStringify.js +2 -2
  87. package/package.json +5 -1
  88. package/docs/README.md +0 -72
  89. package/docs/_media/modules.md +0 -58
  90. package/docs/arrayUtils/-internal-.md +0 -179
  91. package/docs/arrayUtils/README.md +0 -550
  92. package/docs/assertions/-internal-.md +0 -63
  93. package/docs/assertions/README.md +0 -565
  94. package/docs/asyncQueue/-internal-.md +0 -297
  95. package/docs/asyncQueue/README.md +0 -1485
  96. package/docs/awaitDebounce.md +0 -66
  97. package/docs/cache/-internal-.md +0 -168
  98. package/docs/cache/README.md +0 -360
  99. package/docs/castValues.md +0 -47
  100. package/docs/concurrentCalls/-internal-.md +0 -490
  101. package/docs/concurrentCalls/README.md +0 -299
  102. package/docs/consoleFmt.md +0 -115
  103. package/docs/conversions.md +0 -27
  104. package/docs/createThrottleController/-internal-.md +0 -73
  105. package/docs/createThrottleController/README.md +0 -31
  106. package/docs/debounce.md +0 -188
  107. package/docs/dedent/-internal-.md +0 -17
  108. package/docs/dedent/README.md +0 -204
  109. package/docs/deepEqual.md +0 -94
  110. package/docs/enhancedMap.md +0 -358
  111. package/docs/exhaustiveMatch/-internal-.md +0 -39
  112. package/docs/exhaustiveMatch/README.md +0 -146
  113. package/docs/filterObjectOrArrayKeys.md +0 -109
  114. package/docs/getAutoIncrementId.md +0 -93
  115. package/docs/getCompositeKey.md +0 -39
  116. package/docs/getValueStableKey.md +0 -57
  117. package/docs/hash.md +0 -31
  118. package/docs/interpolate/-internal-.md +0 -61
  119. package/docs/interpolate/README.md +0 -62
  120. package/docs/keepPrevIfUnchanged.md +0 -43
  121. package/docs/levenshtein.md +0 -93
  122. package/docs/main.md +0 -21
  123. package/docs/mathUtils.md +0 -137
  124. package/docs/modules.md +0 -58
  125. package/docs/mutationUtils.md +0 -44
  126. package/docs/objUtils.md +0 -237
  127. package/docs/parallelAsyncCalls/-internal-.md +0 -347
  128. package/docs/parallelAsyncCalls/README.md +0 -45
  129. package/docs/promiseUtils/-internal-.md +0 -69
  130. package/docs/promiseUtils/README.md +0 -31
  131. package/docs/retryOnError/-internal-.md +0 -111
  132. package/docs/retryOnError/README.md +0 -168
  133. package/docs/runShellCmd/-internal-.md +0 -111
  134. package/docs/runShellCmd/README.md +0 -201
  135. package/docs/safeJson.md +0 -51
  136. package/docs/saferTyping.md +0 -228
  137. package/docs/serializeXML.md +0 -100
  138. package/docs/shallowEqual.md +0 -33
  139. package/docs/sleep.md +0 -27
  140. package/docs/stringUtils/-internal-.md +0 -17
  141. package/docs/stringUtils/README.md +0 -270
  142. package/docs/testUtils.md +0 -382
  143. package/docs/throttle/-internal-.md +0 -47
  144. package/docs/throttle/README.md +0 -178
  145. package/docs/time.md +0 -274
  146. package/docs/timers.md +0 -256
  147. package/docs/tsResult/-internal-.md +0 -327
  148. package/docs/tsResult/README.md +0 -702
  149. package/docs/typeGuards.md +0 -399
  150. package/docs/typeUtils/-internal-.md +0 -99
  151. package/docs/typeUtils/README.md +0 -195
  152. package/docs/typeUtils.typesTest.md +0 -7
  153. package/docs/typedStrings.md +0 -458
  154. package/docs/typingFnUtils/-internal-.md +0 -43
  155. package/docs/typingFnUtils/README.md +0 -317
  156. package/docs/typingTestUtils.md +0 -172
  157. package/docs/typingUtils.md +0 -135
  158. package/docs/yamlStringify.md +0 -83
package/docs/time.md DELETED
@@ -1,274 +0,0 @@
1
- [**@ls-stack/utils**](README.md)
2
-
3
- ***
4
-
5
- [@ls-stack/utils](modules.md) / time
6
-
7
- # time
8
-
9
- ## Type Aliases
10
-
11
- ### DurationObj
12
-
13
- ```ts
14
- type DurationObj = object;
15
- ```
16
-
17
- Defined in: [packages/utils/src/time.ts:111](https://github.com/lucasols/utils/blob/main/packages/utils/src/time.ts#L111)
18
-
19
- #### Properties
20
-
21
- ##### days?
22
-
23
- ```ts
24
- optional days: number;
25
- ```
26
-
27
- Defined in: [packages/utils/src/time.ts:116](https://github.com/lucasols/utils/blob/main/packages/utils/src/time.ts#L116)
28
-
29
- ##### hours?
30
-
31
- ```ts
32
- optional hours: number;
33
- ```
34
-
35
- Defined in: [packages/utils/src/time.ts:115](https://github.com/lucasols/utils/blob/main/packages/utils/src/time.ts#L115)
36
-
37
- ##### minutes?
38
-
39
- ```ts
40
- optional minutes: number;
41
- ```
42
-
43
- Defined in: [packages/utils/src/time.ts:114](https://github.com/lucasols/utils/blob/main/packages/utils/src/time.ts#L114)
44
-
45
- ##### ms?
46
-
47
- ```ts
48
- optional ms: number;
49
- ```
50
-
51
- Defined in: [packages/utils/src/time.ts:112](https://github.com/lucasols/utils/blob/main/packages/utils/src/time.ts#L112)
52
-
53
- ##### seconds?
54
-
55
- ```ts
56
- optional seconds: number;
57
- ```
58
-
59
- Defined in: [packages/utils/src/time.ts:113](https://github.com/lucasols/utils/blob/main/packages/utils/src/time.ts#L113)
60
-
61
- ## Variables
62
-
63
- ### DAY\_AS\_MS
64
-
65
- ```ts
66
- const DAY_AS_MS: number;
67
- ```
68
-
69
- Defined in: [packages/utils/src/time.ts:6](https://github.com/lucasols/utils/blob/main/packages/utils/src/time.ts#L6)
70
-
71
- ***
72
-
73
- ### DAY\_AS\_SECS
74
-
75
- ```ts
76
- const DAY_AS_SECS: number;
77
- ```
78
-
79
- Defined in: [packages/utils/src/time.ts:12](https://github.com/lucasols/utils/blob/main/packages/utils/src/time.ts#L12)
80
-
81
- ***
82
-
83
- ### HOUR\_AS\_MS
84
-
85
- ```ts
86
- const HOUR_AS_MS: number;
87
- ```
88
-
89
- Defined in: [packages/utils/src/time.ts:5](https://github.com/lucasols/utils/blob/main/packages/utils/src/time.ts#L5)
90
-
91
- ***
92
-
93
- ### HOUR\_AS\_SECS
94
-
95
- ```ts
96
- const HOUR_AS_SECS: number;
97
- ```
98
-
99
- Defined in: [packages/utils/src/time.ts:11](https://github.com/lucasols/utils/blob/main/packages/utils/src/time.ts#L11)
100
-
101
- ***
102
-
103
- ### MINUTE\_AS\_MS
104
-
105
- ```ts
106
- const MINUTE_AS_MS: number;
107
- ```
108
-
109
- Defined in: [packages/utils/src/time.ts:4](https://github.com/lucasols/utils/blob/main/packages/utils/src/time.ts#L4)
110
-
111
- ***
112
-
113
- ### MONTH\_AS\_MS
114
-
115
- ```ts
116
- const MONTH_AS_MS: number;
117
- ```
118
-
119
- Defined in: [packages/utils/src/time.ts:8](https://github.com/lucasols/utils/blob/main/packages/utils/src/time.ts#L8)
120
-
121
- ***
122
-
123
- ### MONTH\_AS\_SECS
124
-
125
- ```ts
126
- const MONTH_AS_SECS: number;
127
- ```
128
-
129
- Defined in: [packages/utils/src/time.ts:14](https://github.com/lucasols/utils/blob/main/packages/utils/src/time.ts#L14)
130
-
131
- ***
132
-
133
- ### WEEK\_AS\_MS
134
-
135
- ```ts
136
- const WEEK_AS_MS: number;
137
- ```
138
-
139
- Defined in: [packages/utils/src/time.ts:7](https://github.com/lucasols/utils/blob/main/packages/utils/src/time.ts#L7)
140
-
141
- ***
142
-
143
- ### WEEK\_AS\_SECS
144
-
145
- ```ts
146
- const WEEK_AS_SECS: number;
147
- ```
148
-
149
- Defined in: [packages/utils/src/time.ts:13](https://github.com/lucasols/utils/blob/main/packages/utils/src/time.ts#L13)
150
-
151
- ***
152
-
153
- ### YEAR\_AS\_MS
154
-
155
- ```ts
156
- const YEAR_AS_MS: number;
157
- ```
158
-
159
- Defined in: [packages/utils/src/time.ts:9](https://github.com/lucasols/utils/blob/main/packages/utils/src/time.ts#L9)
160
-
161
- ***
162
-
163
- ### YEAR\_AS\_SECS
164
-
165
- ```ts
166
- const YEAR_AS_SECS: number;
167
- ```
168
-
169
- Defined in: [packages/utils/src/time.ts:15](https://github.com/lucasols/utils/blob/main/packages/utils/src/time.ts#L15)
170
-
171
- ## Functions
172
-
173
- ### dateStringOrNullToUnixMs()
174
-
175
- ```ts
176
- function dateStringOrNullToUnixMs(isoString): null | number;
177
- ```
178
-
179
- Defined in: [packages/utils/src/time.ts:17](https://github.com/lucasols/utils/blob/main/packages/utils/src/time.ts#L17)
180
-
181
- #### Parameters
182
-
183
- ##### isoString
184
-
185
- `undefined` | `null` | `string`
186
-
187
- #### Returns
188
-
189
- `null` \| `number`
190
-
191
- ***
192
-
193
- ### durationObjToMs()
194
-
195
- ```ts
196
- function durationObjToMs(durationObj): number;
197
- ```
198
-
199
- Defined in: [packages/utils/src/time.ts:119](https://github.com/lucasols/utils/blob/main/packages/utils/src/time.ts#L119)
200
-
201
- #### Parameters
202
-
203
- ##### durationObj
204
-
205
- [`DurationObj`](#durationobj)
206
-
207
- #### Returns
208
-
209
- `number`
210
-
211
- ***
212
-
213
- ### getUnixSeconds()
214
-
215
- ```ts
216
- function getUnixSeconds(): number;
217
- ```
218
-
219
- Defined in: [packages/utils/src/time.ts:107](https://github.com/lucasols/utils/blob/main/packages/utils/src/time.ts#L107)
220
-
221
- #### Returns
222
-
223
- `number`
224
-
225
- ***
226
-
227
- ### msToTimeString()
228
-
229
- ```ts
230
- function msToTimeString(
231
- ms,
232
- format,
233
- hoursMinLength): string;
234
- ```
235
-
236
- Defined in: [packages/utils/src/time.ts:29](https://github.com/lucasols/utils/blob/main/packages/utils/src/time.ts#L29)
237
-
238
- #### Parameters
239
-
240
- ##### ms
241
-
242
- `number`
243
-
244
- ##### format
245
-
246
- `"minutes"` | `"seconds"` | `"milliseconds"`
247
-
248
- ##### hoursMinLength
249
-
250
- `number` = `2`
251
-
252
- #### Returns
253
-
254
- `string`
255
-
256
- ***
257
-
258
- ### parseTimeStringToMs()
259
-
260
- ```ts
261
- function parseTimeStringToMs(timeString): number;
262
- ```
263
-
264
- Defined in: [packages/utils/src/time.ts:59](https://github.com/lucasols/utils/blob/main/packages/utils/src/time.ts#L59)
265
-
266
- #### Parameters
267
-
268
- ##### timeString
269
-
270
- `string`
271
-
272
- #### Returns
273
-
274
- `number`
package/docs/timers.md DELETED
@@ -1,256 +0,0 @@
1
- [**@ls-stack/utils**](README.md)
2
-
3
- ***
4
-
5
- [@ls-stack/utils](modules.md) / timers
6
-
7
- # timers
8
-
9
- ## Type Aliases
10
-
11
- ### CleanupTimer()
12
-
13
- ```ts
14
- type CleanupTimer = () => void;
15
- ```
16
-
17
- Defined in: [packages/utils/src/timers.ts:1](https://github.com/lucasols/utils/blob/main/packages/utils/src/timers.ts#L1)
18
-
19
- #### Returns
20
-
21
- `void`
22
-
23
- ## Functions
24
-
25
- ### createDebouncedTimeout()
26
-
27
- ```ts
28
- function createDebouncedTimeout(ms, callback): object;
29
- ```
30
-
31
- Defined in: [packages/utils/src/timers.ts:94](https://github.com/lucasols/utils/blob/main/packages/utils/src/timers.ts#L94)
32
-
33
- Creates a timeout that prevents concurrent executions.
34
-
35
- Each call to the `call` function will cancel any previous pending timeout
36
- and start a new one. This is useful for debouncing or ensuring only the
37
- last call executes after a delay.
38
-
39
- #### Parameters
40
-
41
- ##### ms
42
-
43
- `number`
44
-
45
- The timeout duration in milliseconds
46
-
47
- ##### callback
48
-
49
- () => `void`
50
-
51
- The function to execute when the timeout completes
52
-
53
- #### Returns
54
-
55
- `object`
56
-
57
- An object with `call` to trigger the timeout and `clean` to cancel it
58
-
59
- ##### call()
60
-
61
- ```ts
62
- call: () => void;
63
- ```
64
-
65
- ###### Returns
66
-
67
- `void`
68
-
69
- ##### clean
70
-
71
- ```ts
72
- clean: CleanupTimer;
73
- ```
74
-
75
- #### Example
76
-
77
- ```typescript
78
- const { call, clean } = createDebouncedTimeout(1000, () => {
79
- console.log('Only the last call executes');
80
- });
81
-
82
- call(); // This will be cancelled
83
- call(); // This will be cancelled
84
- call(); // Only this one will execute after 1000ms
85
-
86
- // Or cancel all pending timeouts
87
- clean();
88
- ```
89
-
90
- ***
91
-
92
- ### createInterval()
93
-
94
- ```ts
95
- function createInterval(ms, callback): CleanupTimer;
96
- ```
97
-
98
- Defined in: [packages/utils/src/timers.ts:56](https://github.com/lucasols/utils/blob/main/packages/utils/src/timers.ts#L56)
99
-
100
- Creates an interval with automatic cleanup capability.
101
-
102
- Returns a cleanup function that can be called to cancel the interval.
103
- The cleanup function is idempotent - calling it multiple times is safe.
104
-
105
- #### Parameters
106
-
107
- ##### ms
108
-
109
- `number`
110
-
111
- The interval duration in milliseconds
112
-
113
- ##### callback
114
-
115
- () => `void`
116
-
117
- The function to execute on each interval tick
118
-
119
- #### Returns
120
-
121
- [`CleanupTimer`](#cleanuptimer)
122
-
123
- A cleanup function that cancels the interval when called
124
-
125
- #### Example
126
-
127
- ```typescript
128
- const cleanup = createInterval(1000, () => {
129
- console.log('Interval tick');
130
- });
131
-
132
- // Stop the interval
133
- cleanup();
134
- ```
135
-
136
- ***
137
-
138
- ### createTimeout()
139
-
140
- ```ts
141
- function createTimeout(ms, callback): CleanupTimer;
142
- ```
143
-
144
- Defined in: [packages/utils/src/timers.ts:23](https://github.com/lucasols/utils/blob/main/packages/utils/src/timers.ts#L23)
145
-
146
- Creates a timeout with automatic cleanup capability.
147
-
148
- Returns a cleanup function that can be called to cancel the timeout.
149
- The cleanup function is idempotent - calling it multiple times is safe.
150
-
151
- #### Parameters
152
-
153
- ##### ms
154
-
155
- `number`
156
-
157
- The timeout duration in milliseconds
158
-
159
- ##### callback
160
-
161
- () => `void`
162
-
163
- The function to execute when the timeout completes
164
-
165
- #### Returns
166
-
167
- [`CleanupTimer`](#cleanuptimer)
168
-
169
- A cleanup function that cancels the timeout when called
170
-
171
- #### Example
172
-
173
- ```typescript
174
- const cleanup = createTimeout(1000, () => {
175
- console.log('Timeout completed');
176
- });
177
-
178
- // Cancel the timeout before it completes
179
- cleanup();
180
- ```
181
-
182
- ***
183
-
184
- ### createWaitUntil()
185
-
186
- ```ts
187
- function createWaitUntil<T>(options): CleanupTimer;
188
- ```
189
-
190
- Defined in: [packages/utils/src/timers.ts:144](https://github.com/lucasols/utils/blob/main/packages/utils/src/timers.ts#L144)
191
-
192
- Creates a timeout that waits for a condition to become true.
193
-
194
- Polls the condition function at regular intervals until it returns a truthy value,
195
- then calls the callback with that value. If the condition doesn't become true
196
- within the maximum wait time, the timeout expires without calling the callback.
197
-
198
- #### Type Parameters
199
-
200
- ##### T
201
-
202
- `T` *extends* `object`
203
-
204
- The type of value returned by the condition function when true
205
-
206
- #### Parameters
207
-
208
- ##### options
209
-
210
- Configuration options
211
-
212
- ###### callback
213
-
214
- (`value`) => `void`
215
-
216
- Function to call when the condition becomes true
217
-
218
- ###### checkIntervalMs?
219
-
220
- `number` = `20`
221
-
222
- How often to check the condition in milliseconds (default: 20)
223
-
224
- ###### condition
225
-
226
- () => `false` \| `T`
227
-
228
- Function that returns false or a truthy value when the condition is met
229
-
230
- ###### maxWaitMs
231
-
232
- `number`
233
-
234
- Maximum time to wait for the condition in milliseconds
235
-
236
- #### Returns
237
-
238
- [`CleanupTimer`](#cleanuptimer)
239
-
240
- A cleanup function that cancels the condition timeout
241
-
242
- #### Example
243
-
244
- ```typescript
245
- const cleanup = createWaitUntil({
246
- condition: () => document.getElementById('myElement'),
247
- maxWaitMs: 5000,
248
- callback: (element) => {
249
- console.log('Element found:', element);
250
- },
251
- checkIntervalMs: 50
252
- });
253
-
254
- // Cancel the condition check
255
- cleanup();
256
- ```