@ls-stack/utils 3.17.1 → 3.19.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 (114) hide show
  1. package/README.md +1 -15
  2. package/docs/README.md +72 -0
  3. package/docs/_media/modules.md +52 -0
  4. package/docs/arrayUtils/-internal-.md +17 -0
  5. package/docs/arrayUtils/README.md +423 -0
  6. package/docs/assertions/-internal-.md +63 -0
  7. package/docs/assertions/README.md +565 -0
  8. package/docs/asyncQueue/-internal-.md +815 -0
  9. package/docs/asyncQueue/README.md +75 -0
  10. package/docs/awaitDebounce.md +66 -0
  11. package/docs/cache/-internal-.md +168 -0
  12. package/docs/cache/README.md +360 -0
  13. package/docs/castValues.md +47 -0
  14. package/docs/concurrentCalls/-internal-.md +416 -0
  15. package/docs/concurrentCalls/README.md +77 -0
  16. package/docs/consoleFmt.md +91 -0
  17. package/docs/conversions.md +27 -0
  18. package/docs/createThrottleController/-internal-.md +73 -0
  19. package/docs/createThrottleController/README.md +31 -0
  20. package/docs/debounce.md +188 -0
  21. package/docs/dedent.md +117 -0
  22. package/docs/deepEqual.md +94 -0
  23. package/docs/enhancedMap.md +358 -0
  24. package/docs/exhaustiveMatch/-internal-.md +39 -0
  25. package/docs/exhaustiveMatch/README.md +146 -0
  26. package/docs/getAutoIncrementId.md +93 -0
  27. package/docs/getCompositeKey.md +39 -0
  28. package/docs/getValueStableKey.md +57 -0
  29. package/docs/hash.md +31 -0
  30. package/docs/interpolate/-internal-.md +61 -0
  31. package/docs/interpolate/README.md +62 -0
  32. package/docs/levenshtein.md +93 -0
  33. package/docs/main.md +21 -0
  34. package/docs/mathUtils.md +137 -0
  35. package/docs/modules.md +52 -0
  36. package/docs/objUtils.md +237 -0
  37. package/docs/parallelAsyncCalls/-internal-.md +347 -0
  38. package/docs/parallelAsyncCalls/README.md +45 -0
  39. package/docs/promiseUtils/-internal-.md +69 -0
  40. package/docs/promiseUtils/README.md +31 -0
  41. package/docs/retryOnError.md +67 -0
  42. package/docs/runShellCmd/-internal-.md +111 -0
  43. package/docs/runShellCmd/README.md +201 -0
  44. package/docs/safeJson.md +51 -0
  45. package/docs/saferTyping.md +228 -0
  46. package/docs/serializeXML.md +100 -0
  47. package/docs/shallowEqual.md +33 -0
  48. package/docs/sleep.md +27 -0
  49. package/docs/stringUtils/-internal-.md +17 -0
  50. package/docs/stringUtils/README.md +166 -0
  51. package/docs/testUtils.md +315 -0
  52. package/docs/throttle/-internal-.md +47 -0
  53. package/docs/throttle/README.md +178 -0
  54. package/docs/time.md +274 -0
  55. package/docs/timers.md +256 -0
  56. package/docs/tsResult/-internal-.md +327 -0
  57. package/docs/tsResult/README.md +696 -0
  58. package/docs/typeGuards.md +399 -0
  59. package/docs/typingFnUtils/-internal-.md +27 -0
  60. package/docs/typingFnUtils/README.md +293 -0
  61. package/docs/typingTestUtils.md +172 -0
  62. package/docs/typingUtils.md +111 -0
  63. package/docs/yamlStringify.md +45 -0
  64. package/lib/arrayUtils.js +3 -3
  65. package/lib/assertions.js +2 -2
  66. package/lib/awaitDebounce.cjs +106 -0
  67. package/lib/awaitDebounce.d.cts +38 -0
  68. package/lib/awaitDebounce.d.ts +38 -0
  69. package/lib/awaitDebounce.js +28 -0
  70. package/lib/cache.js +2 -2
  71. package/lib/{chunk-NH2LCAQS.js → chunk-6FIBVC2P.js} +1 -1
  72. package/lib/{chunk-GKOTKAIV.js → chunk-7CQPOM5I.js} +1 -1
  73. package/lib/{chunk-WS4WEVHU.js → chunk-C2SVCIWE.js} +1 -1
  74. package/lib/{chunk-SSKW673U.js → chunk-JF2MDHOJ.js} +5 -1
  75. package/lib/chunk-NW5H5EW7.js +100 -0
  76. package/lib/{chunk-DMW5Q4T2.js → chunk-SRVMMYSW.js} +1 -1
  77. package/lib/concurrentCalls.js +3 -3
  78. package/lib/createThrottleController.js +3 -3
  79. package/lib/debounce.js +4 -95
  80. package/lib/enhancedMap.js +3 -3
  81. package/lib/getAutoIncrementId.cjs +44 -0
  82. package/lib/getAutoIncrementId.d.cts +44 -0
  83. package/lib/getAutoIncrementId.d.ts +44 -0
  84. package/lib/getAutoIncrementId.js +18 -0
  85. package/lib/getCompositeKey.js +3 -3
  86. package/lib/getValueStableKey.js +3 -3
  87. package/lib/interpolate.js +2 -2
  88. package/lib/parallelAsyncCalls.js +2 -2
  89. package/lib/runShellCmd.d.cts +50 -0
  90. package/lib/runShellCmd.d.ts +50 -0
  91. package/lib/serializeXML.cjs +7 -2
  92. package/lib/serializeXML.d.cts +1 -1
  93. package/lib/serializeXML.d.ts +1 -1
  94. package/lib/serializeXML.js +7 -5
  95. package/lib/testUtils.js +3 -3
  96. package/lib/throttle.cjs +250 -0
  97. package/lib/throttle.d.cts +89 -0
  98. package/lib/throttle.d.ts +89 -0
  99. package/lib/throttle.js +38 -0
  100. package/lib/timers.cjs +93 -0
  101. package/lib/timers.d.cts +110 -0
  102. package/lib/timers.d.ts +110 -0
  103. package/lib/timers.js +65 -0
  104. package/lib/tsResult.js +2 -2
  105. package/lib/typeGuards.cjs +7 -2
  106. package/lib/typeGuards.d.cts +2 -1
  107. package/lib/typeGuards.d.ts +2 -1
  108. package/lib/typeGuards.js +5 -3
  109. package/lib/typingFnUtils.cjs +5 -1
  110. package/lib/typingFnUtils.d.cts +1 -1
  111. package/lib/typingFnUtils.d.ts +1 -1
  112. package/lib/typingFnUtils.js +5 -1
  113. package/lib/yamlStringify.js +5 -5
  114. package/package.json +26 -12
@@ -0,0 +1,188 @@
1
+ [**@ls-stack/utils**](README.md)
2
+
3
+ ***
4
+
5
+ [@ls-stack/utils](modules.md) / debounce
6
+
7
+ # debounce
8
+
9
+ ## Interfaces
10
+
11
+ ### DebouncedFunc()\<T\>
12
+
13
+ Defined in: [packages/utils/src/debounce.ts:16](https://github.com/lucasols/utils/blob/main/packages/utils/src/debounce.ts#L16)
14
+
15
+ #### Type Parameters
16
+
17
+ ##### T
18
+
19
+ `T` *extends* (...`args`) => `void`
20
+
21
+ ```ts
22
+ DebouncedFunc(...args): undefined | ReturnType<T>;
23
+ ```
24
+
25
+ Defined in: [packages/utils/src/debounce.ts:26](https://github.com/lucasols/utils/blob/main/packages/utils/src/debounce.ts#L26)
26
+
27
+ Call the original function, but applying the debounce rules.
28
+
29
+ If the debounced function can be run immediately, this calls it and returns its return
30
+ value.
31
+
32
+ Otherwise, it returns the return value of the last invocation, or undefined if the debounced
33
+ function was not invoked yet.
34
+
35
+ #### Parameters
36
+
37
+ ##### args
38
+
39
+ ...`Parameters`\<`T`\>
40
+
41
+ #### Returns
42
+
43
+ `undefined` \| `ReturnType`\<`T`\>
44
+
45
+ #### Properties
46
+
47
+ ##### cancel()
48
+
49
+ ```ts
50
+ cancel: () => void;
51
+ ```
52
+
53
+ Defined in: [packages/utils/src/debounce.ts:31](https://github.com/lucasols/utils/blob/main/packages/utils/src/debounce.ts#L31)
54
+
55
+ Throw away any pending invocation of the debounced function.
56
+
57
+ ###### Returns
58
+
59
+ `void`
60
+
61
+ ##### flush()
62
+
63
+ ```ts
64
+ flush: () => undefined | ReturnType<T>;
65
+ ```
66
+
67
+ Defined in: [packages/utils/src/debounce.ts:40](https://github.com/lucasols/utils/blob/main/packages/utils/src/debounce.ts#L40)
68
+
69
+ If there is a pending invocation of the debounced function, invoke it immediately and return
70
+ its return value.
71
+
72
+ Otherwise, return the value from the last invocation, or undefined if the debounced function
73
+ was never invoked.
74
+
75
+ ###### Returns
76
+
77
+ `undefined` \| `ReturnType`\<`T`\>
78
+
79
+ ## Type Aliases
80
+
81
+ ### DebounceOptions
82
+
83
+ ```ts
84
+ type DebounceOptions = object;
85
+ ```
86
+
87
+ Defined in: [packages/utils/src/debounce.ts:1](https://github.com/lucasols/utils/blob/main/packages/utils/src/debounce.ts#L1)
88
+
89
+ #### Properties
90
+
91
+ ##### leading?
92
+
93
+ ```ts
94
+ optional leading: boolean;
95
+ ```
96
+
97
+ Defined in: [packages/utils/src/debounce.ts:5](https://github.com/lucasols/utils/blob/main/packages/utils/src/debounce.ts#L5)
98
+
99
+ ###### See
100
+
101
+ _.leading
102
+
103
+ ##### maxWait?
104
+
105
+ ```ts
106
+ optional maxWait: number;
107
+ ```
108
+
109
+ Defined in: [packages/utils/src/debounce.ts:9](https://github.com/lucasols/utils/blob/main/packages/utils/src/debounce.ts#L9)
110
+
111
+ ###### See
112
+
113
+ _.maxWait
114
+
115
+ ##### trailing?
116
+
117
+ ```ts
118
+ optional trailing: boolean;
119
+ ```
120
+
121
+ Defined in: [packages/utils/src/debounce.ts:13](https://github.com/lucasols/utils/blob/main/packages/utils/src/debounce.ts#L13)
122
+
123
+ ###### See
124
+
125
+ _.trailing
126
+
127
+ ## Functions
128
+
129
+ ### debounce()
130
+
131
+ ```ts
132
+ function debounce<T>(
133
+ func,
134
+ wait,
135
+ options?): DebouncedFunc<T>;
136
+ ```
137
+
138
+ Defined in: [packages/utils/src/debounce.ts:44](https://github.com/lucasols/utils/blob/main/packages/utils/src/debounce.ts#L44)
139
+
140
+ #### Type Parameters
141
+
142
+ ##### T
143
+
144
+ `T` *extends* (...`args`) => `void`
145
+
146
+ #### Parameters
147
+
148
+ ##### func
149
+
150
+ `T`
151
+
152
+ ##### wait
153
+
154
+ `number`
155
+
156
+ ##### options?
157
+
158
+ [`DebounceOptions`](#debounceoptions)
159
+
160
+ #### Returns
161
+
162
+ [`DebouncedFunc`](#debouncedfunc)\<`T`\>
163
+
164
+ ***
165
+
166
+ ### isDebouncedFn()
167
+
168
+ ```ts
169
+ function isDebouncedFn<T>(fn): fn is T & { cancel: () => void; flush: () => undefined | ReturnType<T> };
170
+ ```
171
+
172
+ Defined in: [packages/utils/src/debounce.ts:176](https://github.com/lucasols/utils/blob/main/packages/utils/src/debounce.ts#L176)
173
+
174
+ #### Type Parameters
175
+
176
+ ##### T
177
+
178
+ `T` *extends* (...`args`) => `void`
179
+
180
+ #### Parameters
181
+
182
+ ##### fn
183
+
184
+ `T`
185
+
186
+ #### Returns
187
+
188
+ fn is T & \{ cancel: () =\> void; flush: () =\> undefined \| ReturnType\<T\> \}
package/docs/dedent.md ADDED
@@ -0,0 +1,117 @@
1
+ [**@ls-stack/utils**](README.md)
2
+
3
+ ***
4
+
5
+ [@ls-stack/utils](modules.md) / dedent
6
+
7
+ # dedent
8
+
9
+ ## Interfaces
10
+
11
+ ### Dedent()
12
+
13
+ Defined in: [packages/utils/src/dedent.ts:6](https://github.com/lucasols/utils/blob/main/packages/utils/src/dedent.ts#L6)
14
+
15
+ #### Call Signature
16
+
17
+ ```ts
18
+ Dedent(literals): string;
19
+ ```
20
+
21
+ Defined in: [packages/utils/src/dedent.ts:7](https://github.com/lucasols/utils/blob/main/packages/utils/src/dedent.ts#L7)
22
+
23
+ ##### Parameters
24
+
25
+ ###### literals
26
+
27
+ `string`
28
+
29
+ ##### Returns
30
+
31
+ `string`
32
+
33
+ #### Call Signature
34
+
35
+ ```ts
36
+ Dedent(strings, ...values): string;
37
+ ```
38
+
39
+ Defined in: [packages/utils/src/dedent.ts:8](https://github.com/lucasols/utils/blob/main/packages/utils/src/dedent.ts#L8)
40
+
41
+ ##### Parameters
42
+
43
+ ###### strings
44
+
45
+ `TemplateStringsArray`
46
+
47
+ ###### values
48
+
49
+ ...`unknown`[]
50
+
51
+ ##### Returns
52
+
53
+ `string`
54
+
55
+ #### Properties
56
+
57
+ ##### withOptions
58
+
59
+ ```ts
60
+ withOptions: CreateDedent;
61
+ ```
62
+
63
+ Defined in: [packages/utils/src/dedent.ts:9](https://github.com/lucasols/utils/blob/main/packages/utils/src/dedent.ts#L9)
64
+
65
+ ***
66
+
67
+ ### DedentOptions
68
+
69
+ Defined in: [packages/utils/src/dedent.ts:1](https://github.com/lucasols/utils/blob/main/packages/utils/src/dedent.ts#L1)
70
+
71
+ #### Properties
72
+
73
+ ##### escapeSpecialCharacters?
74
+
75
+ ```ts
76
+ optional escapeSpecialCharacters: boolean;
77
+ ```
78
+
79
+ Defined in: [packages/utils/src/dedent.ts:2](https://github.com/lucasols/utils/blob/main/packages/utils/src/dedent.ts#L2)
80
+
81
+ ##### trimWhitespace?
82
+
83
+ ```ts
84
+ optional trimWhitespace: boolean;
85
+ ```
86
+
87
+ Defined in: [packages/utils/src/dedent.ts:3](https://github.com/lucasols/utils/blob/main/packages/utils/src/dedent.ts#L3)
88
+
89
+ ## Type Aliases
90
+
91
+ ### CreateDedent()
92
+
93
+ ```ts
94
+ type CreateDedent = (options) => Dedent;
95
+ ```
96
+
97
+ Defined in: [packages/utils/src/dedent.ts:12](https://github.com/lucasols/utils/blob/main/packages/utils/src/dedent.ts#L12)
98
+
99
+ #### Parameters
100
+
101
+ ##### options
102
+
103
+ [`DedentOptions`](#dedentoptions)
104
+
105
+ #### Returns
106
+
107
+ [`Dedent`](#dedent)
108
+
109
+ ## Variables
110
+
111
+ ### dedent
112
+
113
+ ```ts
114
+ const dedent: Dedent;
115
+ ```
116
+
117
+ Defined in: [packages/utils/src/dedent.ts:14](https://github.com/lucasols/utils/blob/main/packages/utils/src/dedent.ts#L14)
@@ -0,0 +1,94 @@
1
+ [**@ls-stack/utils**](README.md)
2
+
3
+ ***
4
+
5
+ [@ls-stack/utils](modules.md) / deepEqual
6
+
7
+ # deepEqual
8
+
9
+ ## Functions
10
+
11
+ ### deepEqual()
12
+
13
+ ```ts
14
+ function deepEqual(
15
+ foo,
16
+ bar,
17
+ maxDepth): boolean;
18
+ ```
19
+
20
+ Defined in: [packages/utils/src/deepEqual.ts:30](https://github.com/lucasols/utils/blob/main/packages/utils/src/deepEqual.ts#L30)
21
+
22
+ Deep equality comparison between two values
23
+
24
+ #### Parameters
25
+
26
+ ##### foo
27
+
28
+ `any`
29
+
30
+ First value to compare
31
+
32
+ ##### bar
33
+
34
+ `any`
35
+
36
+ Second value to compare
37
+
38
+ ##### maxDepth
39
+
40
+ `number` = `20`
41
+
42
+ Maximum comparison depth (default: 20)
43
+
44
+ #### Returns
45
+
46
+ `boolean`
47
+
48
+ True if values are deeply equal, false otherwise
49
+
50
+ #### Example
51
+
52
+ ```ts
53
+ deepEqual({a: 1}, {a: 1}) // true
54
+ deepEqual({a: 1}, {a: 2}) // false
55
+ deepEqual([1, {b: 2}], [1, {b: 2}]) // true
56
+ deepEqual(new Map([['a', 1]]), new Map([['a', 1]])) // true
57
+ deepEqual(new Set([1, 2]), new Set([1, 2])) // true
58
+ ```
59
+
60
+ ***
61
+
62
+ ### deepEqualWithMaxDepth()
63
+
64
+ ```ts
65
+ function deepEqualWithMaxDepth(maxDepth): (foo, bar) => boolean;
66
+ ```
67
+
68
+ Defined in: [packages/utils/src/deepEqual.ts:94](https://github.com/lucasols/utils/blob/main/packages/utils/src/deepEqual.ts#L94)
69
+
70
+ #### Parameters
71
+
72
+ ##### maxDepth
73
+
74
+ `number`
75
+
76
+ #### Returns
77
+
78
+ ```ts
79
+ (foo, bar): boolean;
80
+ ```
81
+
82
+ ##### Parameters
83
+
84
+ ###### foo
85
+
86
+ `any`
87
+
88
+ ###### bar
89
+
90
+ `any`
91
+
92
+ ##### Returns
93
+
94
+ `boolean`