@ls-stack/utils 3.39.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 (162) 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/consoleFmt.cjs +1 -0
  23. package/dist/consoleFmt.d.cts +6 -0
  24. package/dist/consoleFmt.d.ts +6 -0
  25. package/dist/consoleFmt.js +1 -0
  26. package/dist/debounce.d.cts +12 -20
  27. package/dist/debounce.d.ts +12 -20
  28. package/dist/dedent.d.cts +31 -31
  29. package/dist/dedent.d.ts +31 -31
  30. package/dist/deepEqual.d.cts +10 -9
  31. package/dist/deepEqual.d.ts +10 -9
  32. package/dist/filterObjectOrArrayKeys.d.cts +44 -19
  33. package/dist/filterObjectOrArrayKeys.d.ts +44 -19
  34. package/dist/getAutoIncrementId.d.cts +25 -23
  35. package/dist/getAutoIncrementId.d.ts +25 -23
  36. package/dist/getCompositeKey.d.cts +2 -1
  37. package/dist/getCompositeKey.d.ts +2 -1
  38. package/dist/getValueStableKey.d.cts +4 -3
  39. package/dist/getValueStableKey.d.ts +4 -3
  40. package/dist/mutationUtils.d.cts +2 -2
  41. package/dist/mutationUtils.d.ts +2 -2
  42. package/dist/objUtils.cjs +51 -2
  43. package/dist/objUtils.d.cts +8 -3
  44. package/dist/objUtils.d.ts +8 -3
  45. package/dist/objUtils.js +11 -3
  46. package/dist/parallelAsyncCalls.cjs +2 -1
  47. package/dist/parallelAsyncCalls.d.cts +5 -4
  48. package/dist/parallelAsyncCalls.d.ts +5 -4
  49. package/dist/parallelAsyncCalls.js +2 -1
  50. package/dist/retryOnError.d.cts +23 -20
  51. package/dist/retryOnError.d.ts +23 -20
  52. package/dist/runShellCmd.d.cts +40 -40
  53. package/dist/runShellCmd.d.ts +40 -40
  54. package/dist/safeJson.d.cts +6 -2
  55. package/dist/safeJson.d.ts +6 -2
  56. package/dist/saferTyping.d.cts +21 -14
  57. package/dist/saferTyping.d.ts +21 -14
  58. package/dist/shallowEqual.d.cts +1 -1
  59. package/dist/shallowEqual.d.ts +1 -1
  60. package/dist/stringUtils.cjs +2 -2
  61. package/dist/stringUtils.d.cts +6 -7
  62. package/dist/stringUtils.d.ts +6 -7
  63. package/dist/stringUtils.js +1 -1
  64. package/dist/testUtils.cjs +11 -9
  65. package/dist/testUtils.d.cts +32 -14
  66. package/dist/testUtils.d.ts +32 -14
  67. package/dist/testUtils.js +4 -3
  68. package/dist/throttle.d.cts +57 -48
  69. package/dist/throttle.d.ts +57 -48
  70. package/dist/timers.d.cts +68 -63
  71. package/dist/timers.d.ts +68 -63
  72. package/dist/tsResult.d.cts +7 -6
  73. package/dist/tsResult.d.ts +7 -6
  74. package/dist/typeGuards.d.cts +65 -64
  75. package/dist/typeGuards.d.ts +65 -64
  76. package/dist/typeUtils.d.cts +18 -4
  77. package/dist/typeUtils.d.ts +18 -4
  78. package/dist/typedStrings.d.cts +68 -57
  79. package/dist/typedStrings.d.ts +68 -57
  80. package/dist/typingFnUtils.d.cts +12 -6
  81. package/dist/typingFnUtils.d.ts +12 -6
  82. package/dist/typingFnUtils.js +12 -35
  83. package/dist/typingTestUtils.cjs +7 -1
  84. package/dist/typingTestUtils.d.cts +52 -11
  85. package/dist/typingTestUtils.d.ts +52 -11
  86. package/dist/typingTestUtils.js +7 -1
  87. package/dist/typingUtils.d.cts +4 -1
  88. package/dist/typingUtils.d.ts +4 -1
  89. package/dist/yamlStringify.cjs +11 -9
  90. package/dist/yamlStringify.js +2 -2
  91. package/package.json +6 -2
  92. package/docs/README.md +0 -72
  93. package/docs/_media/modules.md +0 -58
  94. package/docs/arrayUtils/-internal-.md +0 -179
  95. package/docs/arrayUtils/README.md +0 -550
  96. package/docs/assertions/-internal-.md +0 -63
  97. package/docs/assertions/README.md +0 -565
  98. package/docs/asyncQueue/-internal-.md +0 -297
  99. package/docs/asyncQueue/README.md +0 -1485
  100. package/docs/awaitDebounce.md +0 -66
  101. package/docs/cache/-internal-.md +0 -168
  102. package/docs/cache/README.md +0 -360
  103. package/docs/castValues.md +0 -47
  104. package/docs/concurrentCalls/-internal-.md +0 -490
  105. package/docs/concurrentCalls/README.md +0 -299
  106. package/docs/consoleFmt.md +0 -91
  107. package/docs/conversions.md +0 -27
  108. package/docs/createThrottleController/-internal-.md +0 -73
  109. package/docs/createThrottleController/README.md +0 -31
  110. package/docs/debounce.md +0 -188
  111. package/docs/dedent/-internal-.md +0 -17
  112. package/docs/dedent/README.md +0 -204
  113. package/docs/deepEqual.md +0 -94
  114. package/docs/enhancedMap.md +0 -358
  115. package/docs/exhaustiveMatch/-internal-.md +0 -39
  116. package/docs/exhaustiveMatch/README.md +0 -146
  117. package/docs/filterObjectOrArrayKeys.md +0 -109
  118. package/docs/getAutoIncrementId.md +0 -93
  119. package/docs/getCompositeKey.md +0 -39
  120. package/docs/getValueStableKey.md +0 -57
  121. package/docs/hash.md +0 -31
  122. package/docs/interpolate/-internal-.md +0 -61
  123. package/docs/interpolate/README.md +0 -62
  124. package/docs/keepPrevIfUnchanged.md +0 -43
  125. package/docs/levenshtein.md +0 -93
  126. package/docs/main.md +0 -21
  127. package/docs/mathUtils.md +0 -137
  128. package/docs/modules.md +0 -58
  129. package/docs/mutationUtils.md +0 -44
  130. package/docs/objUtils.md +0 -237
  131. package/docs/parallelAsyncCalls/-internal-.md +0 -347
  132. package/docs/parallelAsyncCalls/README.md +0 -45
  133. package/docs/promiseUtils/-internal-.md +0 -69
  134. package/docs/promiseUtils/README.md +0 -31
  135. package/docs/retryOnError/-internal-.md +0 -111
  136. package/docs/retryOnError/README.md +0 -168
  137. package/docs/runShellCmd/-internal-.md +0 -111
  138. package/docs/runShellCmd/README.md +0 -201
  139. package/docs/safeJson.md +0 -51
  140. package/docs/saferTyping.md +0 -228
  141. package/docs/serializeXML.md +0 -100
  142. package/docs/shallowEqual.md +0 -33
  143. package/docs/sleep.md +0 -27
  144. package/docs/stringUtils/-internal-.md +0 -17
  145. package/docs/stringUtils/README.md +0 -270
  146. package/docs/testUtils.md +0 -382
  147. package/docs/throttle/-internal-.md +0 -47
  148. package/docs/throttle/README.md +0 -178
  149. package/docs/time.md +0 -274
  150. package/docs/timers.md +0 -256
  151. package/docs/tsResult/-internal-.md +0 -327
  152. package/docs/tsResult/README.md +0 -702
  153. package/docs/typeGuards.md +0 -399
  154. package/docs/typeUtils/-internal-.md +0 -99
  155. package/docs/typeUtils/README.md +0 -195
  156. package/docs/typeUtils.typesTest.md +0 -7
  157. package/docs/typedStrings.md +0 -458
  158. package/docs/typingFnUtils/-internal-.md +0 -43
  159. package/docs/typingFnUtils/README.md +0 -317
  160. package/docs/typingTestUtils.md +0 -172
  161. package/docs/typingUtils.md +0 -135
  162. package/docs/yamlStringify.md +0 -83
@@ -2,22 +2,27 @@
2
2
  * Filters the keys of an object based on the provided patterns.
3
3
  *
4
4
  * Filtering patterns in `rejectKeys` and `filterKeys`:
5
+ *
5
6
  * - `'prop'` - Only root-level properties named 'prop'
6
7
  * - `'**prop'` - Any property named exactly 'prop' at any level (root or nested)
7
- * - `'*.prop'` - Any nested property named 'prop' at second level (excludes root-level matches)
8
+ * - `'*.prop'` - Any nested property named 'prop' at second level (excludes
9
+ * root-level matches)
8
10
  * - `'test.*.prop'` - Any property named 'prop' at second level of 'test'
9
11
  * - `'test.*.test.**prop'` - Any property named 'prop' inside of 'test.*.test'
10
12
  * - `'prop.nested'` - Exact nested property paths like `obj.prop.nested`
11
- * - `'prop.**nested'` - All nested properties inside root `prop` with name `nested`
13
+ * - `'prop.**nested'` - All nested properties inside root `prop` with name
14
+ * `nested`
12
15
  * - `'prop[0]'` - The first item of the `prop` array
13
16
  * - `'prop[*]'` - All items of the `prop` array
14
17
  * - `'prop[0].nested'` - `nested` prop of the first item of the `prop` array
15
18
  * - `'prop[*].nested'` - `nested` prop of all items of the `prop` array
16
19
  * - `'prop[*]**nested'` - all `nested` props of all items of the `prop` array
17
20
  * - `'prop[0-2]'` - The first three items of the `prop` array
18
- * - `'prop[4-*]'` - All items of the `prop` array from the fourth index to the end
21
+ * - `'prop[4-*]'` - All items of the `prop` array from the fourth index to the
22
+ * end
19
23
  * - `'prop[0-2].nested.**prop'` - Combining multiple nested patterns is supported
20
24
  * - Root array:
25
+ *
21
26
  * - `'[0]'` - The first item of the root array
22
27
  * - `'[*]'` - All items of the array
23
28
  * - `'[0].nested'` - `nested` prop of the first item of the array
@@ -26,30 +31,50 @@
26
31
  * - `'[0-2]'` - The first three items of the array
27
32
  * - `'[4-*]'` - All items of the array from the fourth index to the end
28
33
  * - Pattern expansion with parentheses:
29
- * - `'prop.test.(prop1|prop2|prop3)'` - Expands to `prop.test.prop1`, `prop.test.prop2`, and `prop.test.prop3`
30
- * - `'components[*].(table_id|columns|filters[*].value)'` - Expands to `components[*].table_id`, `components[*].columns`, and `components[*].filters[*].value`
34
+ *
35
+ * - `'prop.test.(prop1|prop2|prop3)'` - Expands to `prop.test.prop1`,
36
+ * `prop.test.prop2`, and `prop.test.prop3`
37
+ * - `'components[*].(table_id|columns|filters[*].value)'` - Expands to
38
+ * `components[*].table_id`, `components[*].columns`, and
39
+ * `components[*].filters[*].value`
31
40
  * - `'(users|admins)[*].name'` - Expands to `users[*].name` and `admins[*].name`
32
41
  * - Array filtering by value:
33
- * - `'users[%name="John"]'` - Filters the `users` with the `name` property equal to `John`
34
- * - `'users[%name="John" | "Jane"]'` - Value-level OR using `|` for multiple values of same property
35
- * - `'users[%name="Alice" || %age=35]'` - Property-level OR using `||` for different properties
36
- * - `'users[%age=30 && %role="admin"]'` - Property-level AND using `&&` for different properties
37
- * - Note: Mixing `&&` and `||` in the same filter is not supported - use separate filter patterns instead
42
+ *
43
+ * - `'users[%name="John"]'` - Filters the `users` with the `name` property equal
44
+ * to `John`
45
+ * - `'users[%name="John" | "Jane"]'` - Value-level OR using `|` for multiple
46
+ * values of same property
47
+ * - `'users[%name="Alice" || %age=35]'` - Property-level OR using `||` for
48
+ * different properties
49
+ * - `'users[%age=30 && %role="admin"]'` - Property-level AND using `&&` for
50
+ * different properties
51
+ * - Note: Mixing `&&` and `||` in the same filter is not supported - use separate
52
+ * filter patterns instead
38
53
  * - `'users[%config.name="John" | "Jane"]'` - Dot notation is supported
39
- * - `'users[%name*="oh"]'` - Contains operator (*=) - filters users where name contains "oh"
40
- * - `'users[%name^="Jo"]'` - Starts with operator (^=) - filters users where name starts with "Jo"
41
- * - `'users[%name$="hn"]'` - Ends with operator ($=) - filters users where name ends with "hn"
42
- * - `'users[%name!="John"]'` - Not equal operator (!=) - filters users where name is not "John"
43
- * - `'users[%name!*="admin"]'` - Not contains operator (!*=) - filters users where name doesn't contain "admin"
44
- * - `'users[i%name="john"]'` - Case-insensitive matching (i% prefix) - matches "John", "JOHN", "john", etc.
54
+ * - `'users[%name*="oh"]'` - Contains operator (*=) - filters users where name
55
+ * contains "oh"
56
+ * - `'users[%name^="Jo"]'` - Starts with operator (^=) - filters users where name
57
+ * starts with "Jo"
58
+ * - `'users[%name$="hn"]'` - Ends with operator ($=) - filters users where name
59
+ * ends with "hn"
60
+ * - `'users[%name!="John"]'` - Not equal operator (!=) - filters users where name
61
+ * is not "John"
62
+ * - `'users[%name!*="admin"]'` - Not contains operator (!*=) - filters users
63
+ * where name doesn't contain "admin"
64
+ * - `'users[i%name="john"]'` - Case-insensitive matching (i% prefix) - matches
65
+ * "John", "JOHN", "john", etc.
45
66
  *
46
67
  * @param objOrArray - The object or array to filter.
47
68
  * @param options - The options for the filter.
48
69
  * @param options.filterKeys - The keys to filter.
49
70
  * @param options.rejectKeys - The keys to reject.
50
- * @param options.rejectEmptyObjectsInArray - Whether to reject empty objects in arrays (default: true).
51
- * @param options.sortKeys - Sort all keys by a specific order (optional, preserves original order when not specified).
52
- * @param options.sortPatterns - Sort specific keys by pattern. Use to control the order of specific properties. The same patterns as `filterKeys` are supported.
71
+ * @param options.rejectEmptyObjectsInArray - Whether to reject empty objects in
72
+ * arrays (default: true).
73
+ * @param options.sortKeys - Sort all keys by a specific order (optional,
74
+ * preserves original order when not specified).
75
+ * @param options.sortPatterns - Sort specific keys by pattern. Use to control
76
+ * the order of specific properties. The same patterns as `filterKeys` are
77
+ * supported.
53
78
  * @returns The filtered object or array.
54
79
  */
55
80
  declare function filterObjectOrArrayKeys(objOrArray: Record<string, any> | Record<string, any>[], { filterKeys, rejectKeys, rejectEmptyObjectsInArray, sortKeys, sortPatterns, }: {
@@ -2,22 +2,27 @@
2
2
  * Filters the keys of an object based on the provided patterns.
3
3
  *
4
4
  * Filtering patterns in `rejectKeys` and `filterKeys`:
5
+ *
5
6
  * - `'prop'` - Only root-level properties named 'prop'
6
7
  * - `'**prop'` - Any property named exactly 'prop' at any level (root or nested)
7
- * - `'*.prop'` - Any nested property named 'prop' at second level (excludes root-level matches)
8
+ * - `'*.prop'` - Any nested property named 'prop' at second level (excludes
9
+ * root-level matches)
8
10
  * - `'test.*.prop'` - Any property named 'prop' at second level of 'test'
9
11
  * - `'test.*.test.**prop'` - Any property named 'prop' inside of 'test.*.test'
10
12
  * - `'prop.nested'` - Exact nested property paths like `obj.prop.nested`
11
- * - `'prop.**nested'` - All nested properties inside root `prop` with name `nested`
13
+ * - `'prop.**nested'` - All nested properties inside root `prop` with name
14
+ * `nested`
12
15
  * - `'prop[0]'` - The first item of the `prop` array
13
16
  * - `'prop[*]'` - All items of the `prop` array
14
17
  * - `'prop[0].nested'` - `nested` prop of the first item of the `prop` array
15
18
  * - `'prop[*].nested'` - `nested` prop of all items of the `prop` array
16
19
  * - `'prop[*]**nested'` - all `nested` props of all items of the `prop` array
17
20
  * - `'prop[0-2]'` - The first three items of the `prop` array
18
- * - `'prop[4-*]'` - All items of the `prop` array from the fourth index to the end
21
+ * - `'prop[4-*]'` - All items of the `prop` array from the fourth index to the
22
+ * end
19
23
  * - `'prop[0-2].nested.**prop'` - Combining multiple nested patterns is supported
20
24
  * - Root array:
25
+ *
21
26
  * - `'[0]'` - The first item of the root array
22
27
  * - `'[*]'` - All items of the array
23
28
  * - `'[0].nested'` - `nested` prop of the first item of the array
@@ -26,30 +31,50 @@
26
31
  * - `'[0-2]'` - The first three items of the array
27
32
  * - `'[4-*]'` - All items of the array from the fourth index to the end
28
33
  * - Pattern expansion with parentheses:
29
- * - `'prop.test.(prop1|prop2|prop3)'` - Expands to `prop.test.prop1`, `prop.test.prop2`, and `prop.test.prop3`
30
- * - `'components[*].(table_id|columns|filters[*].value)'` - Expands to `components[*].table_id`, `components[*].columns`, and `components[*].filters[*].value`
34
+ *
35
+ * - `'prop.test.(prop1|prop2|prop3)'` - Expands to `prop.test.prop1`,
36
+ * `prop.test.prop2`, and `prop.test.prop3`
37
+ * - `'components[*].(table_id|columns|filters[*].value)'` - Expands to
38
+ * `components[*].table_id`, `components[*].columns`, and
39
+ * `components[*].filters[*].value`
31
40
  * - `'(users|admins)[*].name'` - Expands to `users[*].name` and `admins[*].name`
32
41
  * - Array filtering by value:
33
- * - `'users[%name="John"]'` - Filters the `users` with the `name` property equal to `John`
34
- * - `'users[%name="John" | "Jane"]'` - Value-level OR using `|` for multiple values of same property
35
- * - `'users[%name="Alice" || %age=35]'` - Property-level OR using `||` for different properties
36
- * - `'users[%age=30 && %role="admin"]'` - Property-level AND using `&&` for different properties
37
- * - Note: Mixing `&&` and `||` in the same filter is not supported - use separate filter patterns instead
42
+ *
43
+ * - `'users[%name="John"]'` - Filters the `users` with the `name` property equal
44
+ * to `John`
45
+ * - `'users[%name="John" | "Jane"]'` - Value-level OR using `|` for multiple
46
+ * values of same property
47
+ * - `'users[%name="Alice" || %age=35]'` - Property-level OR using `||` for
48
+ * different properties
49
+ * - `'users[%age=30 && %role="admin"]'` - Property-level AND using `&&` for
50
+ * different properties
51
+ * - Note: Mixing `&&` and `||` in the same filter is not supported - use separate
52
+ * filter patterns instead
38
53
  * - `'users[%config.name="John" | "Jane"]'` - Dot notation is supported
39
- * - `'users[%name*="oh"]'` - Contains operator (*=) - filters users where name contains "oh"
40
- * - `'users[%name^="Jo"]'` - Starts with operator (^=) - filters users where name starts with "Jo"
41
- * - `'users[%name$="hn"]'` - Ends with operator ($=) - filters users where name ends with "hn"
42
- * - `'users[%name!="John"]'` - Not equal operator (!=) - filters users where name is not "John"
43
- * - `'users[%name!*="admin"]'` - Not contains operator (!*=) - filters users where name doesn't contain "admin"
44
- * - `'users[i%name="john"]'` - Case-insensitive matching (i% prefix) - matches "John", "JOHN", "john", etc.
54
+ * - `'users[%name*="oh"]'` - Contains operator (*=) - filters users where name
55
+ * contains "oh"
56
+ * - `'users[%name^="Jo"]'` - Starts with operator (^=) - filters users where name
57
+ * starts with "Jo"
58
+ * - `'users[%name$="hn"]'` - Ends with operator ($=) - filters users where name
59
+ * ends with "hn"
60
+ * - `'users[%name!="John"]'` - Not equal operator (!=) - filters users where name
61
+ * is not "John"
62
+ * - `'users[%name!*="admin"]'` - Not contains operator (!*=) - filters users
63
+ * where name doesn't contain "admin"
64
+ * - `'users[i%name="john"]'` - Case-insensitive matching (i% prefix) - matches
65
+ * "John", "JOHN", "john", etc.
45
66
  *
46
67
  * @param objOrArray - The object or array to filter.
47
68
  * @param options - The options for the filter.
48
69
  * @param options.filterKeys - The keys to filter.
49
70
  * @param options.rejectKeys - The keys to reject.
50
- * @param options.rejectEmptyObjectsInArray - Whether to reject empty objects in arrays (default: true).
51
- * @param options.sortKeys - Sort all keys by a specific order (optional, preserves original order when not specified).
52
- * @param options.sortPatterns - Sort specific keys by pattern. Use to control the order of specific properties. The same patterns as `filterKeys` are supported.
71
+ * @param options.rejectEmptyObjectsInArray - Whether to reject empty objects in
72
+ * arrays (default: true).
73
+ * @param options.sortKeys - Sort all keys by a specific order (optional,
74
+ * preserves original order when not specified).
75
+ * @param options.sortPatterns - Sort specific keys by pattern. Use to control
76
+ * the order of specific properties. The same patterns as `filterKeys` are
77
+ * supported.
53
78
  * @returns The filtered object or array.
54
79
  */
55
80
  declare function filterObjectOrArrayKeys(objOrArray: Record<string, any> | Record<string, any>[], { filterKeys, rejectKeys, rejectEmptyObjectsInArray, sortKeys, sortPatterns, }: {
@@ -1,40 +1,42 @@
1
1
  /**
2
- * Returns a unique auto-incrementing number each time it's called.
3
- * This is useful for generating simple unique identifiers within a single session/process.
2
+ * Returns a unique auto-incrementing number each time it's called. This is
3
+ * useful for generating simple unique identifiers within a single
4
+ * session/process.
4
5
  *
5
6
  * **Note:** This is not suitable for distributed systems or persistent storage.
6
- * For cryptographically secure or collision-resistant IDs, use `nanoid()` instead.
7
- *
8
- * @returns A unique incrementing number starting from 1
7
+ * For cryptographically secure or collision-resistant IDs, use `nanoid()`
8
+ * instead.
9
9
  *
10
10
  * @example
11
- * ```ts
12
- * const id1 = getAutoIncrementId(); // 1
13
- * const id2 = getAutoIncrementId(); // 2
14
- * const id3 = getAutoIncrementId(); // 3
15
- * ```
11
+ * ```ts
12
+ * const id1 = getAutoIncrementId(); // 1
13
+ * const id2 = getAutoIncrementId(); // 2
14
+ * const id3 = getAutoIncrementId(); // 3
15
+ * ```;
16
+ *
17
+ * @returns A unique incrementing number starting from 1
16
18
  */
17
19
  declare function getAutoIncrementId(): number;
18
20
  /**
19
21
  * Creates a local auto-increment ID generator with optional prefix and suffix.
20
- * Each generator maintains its own independent counter starting from 1.
21
- * This is useful when you need multiple independent ID sequences or formatted IDs.
22
+ * Each generator maintains its own independent counter starting from 1. This is
23
+ * useful when you need multiple independent ID sequences or formatted IDs.
24
+ *
25
+ * @example
26
+ * ```ts
27
+ * const userIdGen = getLocalAutoIncrementIdGenerator({ prefix: 'user-' });
28
+ * const postIdGen = getLocalAutoIncrementIdGenerator({ prefix: 'post-', suffix: '-draft' });
29
+ *
30
+ * console.log(userIdGen()); // "user-1"
31
+ * console.log(userIdGen()); // "user-2"
32
+ * console.log(postIdGen()); // "post-1-draft"
33
+ * console.log(postIdGen()); // "post-2-draft"
34
+ * ```;
22
35
  *
23
36
  * @param options - Configuration object
24
37
  * @param options.prefix - Optional prefix to prepend to each generated ID
25
38
  * @param options.suffix - Optional suffix to append to each generated ID
26
39
  * @returns A function that generates formatted auto-increment IDs
27
- *
28
- * @example
29
- * ```ts
30
- * const userIdGen = getLocalAutoIncrementIdGenerator({ prefix: 'user-' });
31
- * const postIdGen = getLocalAutoIncrementIdGenerator({ prefix: 'post-', suffix: '-draft' });
32
- *
33
- * console.log(userIdGen()); // "user-1"
34
- * console.log(userIdGen()); // "user-2"
35
- * console.log(postIdGen()); // "post-1-draft"
36
- * console.log(postIdGen()); // "post-2-draft"
37
- * ```
38
40
  */
39
41
  declare function getLocalAutoIncrementIdGenerator({ prefix, suffix, }: {
40
42
  prefix?: string;
@@ -1,40 +1,42 @@
1
1
  /**
2
- * Returns a unique auto-incrementing number each time it's called.
3
- * This is useful for generating simple unique identifiers within a single session/process.
2
+ * Returns a unique auto-incrementing number each time it's called. This is
3
+ * useful for generating simple unique identifiers within a single
4
+ * session/process.
4
5
  *
5
6
  * **Note:** This is not suitable for distributed systems or persistent storage.
6
- * For cryptographically secure or collision-resistant IDs, use `nanoid()` instead.
7
- *
8
- * @returns A unique incrementing number starting from 1
7
+ * For cryptographically secure or collision-resistant IDs, use `nanoid()`
8
+ * instead.
9
9
  *
10
10
  * @example
11
- * ```ts
12
- * const id1 = getAutoIncrementId(); // 1
13
- * const id2 = getAutoIncrementId(); // 2
14
- * const id3 = getAutoIncrementId(); // 3
15
- * ```
11
+ * ```ts
12
+ * const id1 = getAutoIncrementId(); // 1
13
+ * const id2 = getAutoIncrementId(); // 2
14
+ * const id3 = getAutoIncrementId(); // 3
15
+ * ```;
16
+ *
17
+ * @returns A unique incrementing number starting from 1
16
18
  */
17
19
  declare function getAutoIncrementId(): number;
18
20
  /**
19
21
  * Creates a local auto-increment ID generator with optional prefix and suffix.
20
- * Each generator maintains its own independent counter starting from 1.
21
- * This is useful when you need multiple independent ID sequences or formatted IDs.
22
+ * Each generator maintains its own independent counter starting from 1. This is
23
+ * useful when you need multiple independent ID sequences or formatted IDs.
24
+ *
25
+ * @example
26
+ * ```ts
27
+ * const userIdGen = getLocalAutoIncrementIdGenerator({ prefix: 'user-' });
28
+ * const postIdGen = getLocalAutoIncrementIdGenerator({ prefix: 'post-', suffix: '-draft' });
29
+ *
30
+ * console.log(userIdGen()); // "user-1"
31
+ * console.log(userIdGen()); // "user-2"
32
+ * console.log(postIdGen()); // "post-1-draft"
33
+ * console.log(postIdGen()); // "post-2-draft"
34
+ * ```;
22
35
  *
23
36
  * @param options - Configuration object
24
37
  * @param options.prefix - Optional prefix to prepend to each generated ID
25
38
  * @param options.suffix - Optional suffix to append to each generated ID
26
39
  * @returns A function that generates formatted auto-increment IDs
27
- *
28
- * @example
29
- * ```ts
30
- * const userIdGen = getLocalAutoIncrementIdGenerator({ prefix: 'user-' });
31
- * const postIdGen = getLocalAutoIncrementIdGenerator({ prefix: 'post-', suffix: '-draft' });
32
- *
33
- * console.log(userIdGen()); // "user-1"
34
- * console.log(userIdGen()); // "user-2"
35
- * console.log(postIdGen()); // "post-1-draft"
36
- * console.log(postIdGen()); // "post-2-draft"
37
- * ```
38
40
  */
39
41
  declare function getLocalAutoIncrementIdGenerator({ prefix, suffix, }: {
40
42
  prefix?: string;
@@ -2,7 +2,8 @@
2
2
  * Returns a stable key for the input value.
3
3
  *
4
4
  * @param input - The value to get a stable key for.
5
- * @param maxSortingDepth - The maximum depth to sort the input value. Default is 3.
5
+ * @param maxSortingDepth - The maximum depth to sort the input value. Default
6
+ * is 3.
6
7
  * @returns A stable key for the input value.
7
8
  */
8
9
  declare function getCompositeKey(input: unknown, maxSortingDepth?: number): string;
@@ -2,7 +2,8 @@
2
2
  * Returns a stable key for the input value.
3
3
  *
4
4
  * @param input - The value to get a stable key for.
5
- * @param maxSortingDepth - The maximum depth to sort the input value. Default is 3.
5
+ * @param maxSortingDepth - The maximum depth to sort the input value. Default
6
+ * is 3.
6
7
  * @returns A stable key for the input value.
7
8
  */
8
9
  declare function getCompositeKey(input: unknown, maxSortingDepth?: number): string;
@@ -3,11 +3,12 @@ import { getCompositeKey } from './getCompositeKey.cjs';
3
3
  /**
4
4
  * Returns a stable key for the input value.
5
5
  *
6
+ * @deprecated Use `getCompositeKey` from `@ls-stack/utils/getCompositeKey`
7
+ * instead.
6
8
  * @param input - The value to get a stable key for.
7
- * @param maxSortingDepth - The maximum depth to sort the input value. Default is 3.
9
+ * @param maxSortingDepth - The maximum depth to sort the input value. Default
10
+ * is 3.
8
11
  * @returns A stable key for the input value.
9
- *
10
- * @deprecated Use `getCompositeKey` from `@ls-stack/utils/getCompositeKey` instead.
11
12
  */
12
13
  declare const getValueStableKey: typeof getCompositeKey;
13
14
 
@@ -3,11 +3,12 @@ import { getCompositeKey } from './getCompositeKey.js';
3
3
  /**
4
4
  * Returns a stable key for the input value.
5
5
  *
6
+ * @deprecated Use `getCompositeKey` from `@ls-stack/utils/getCompositeKey`
7
+ * instead.
6
8
  * @param input - The value to get a stable key for.
7
- * @param maxSortingDepth - The maximum depth to sort the input value. Default is 3.
9
+ * @param maxSortingDepth - The maximum depth to sort the input value. Default
10
+ * is 3.
8
11
  * @returns A stable key for the input value.
9
- *
10
- * @deprecated Use `getCompositeKey` from `@ls-stack/utils/getCompositeKey` instead.
11
12
  */
12
13
  declare const getValueStableKey: typeof getCompositeKey;
13
14
 
@@ -1,6 +1,6 @@
1
1
  /**
2
- * Updates an object with a new set of values. undefined values are ignored in the updates object
3
- * and deep equal values are not updated.
2
+ * Updates an object with a new set of values. undefined values are ignored in
3
+ * the updates object and deep equal values are not updated.
4
4
  *
5
5
  * @param object - The object to update.
6
6
  * @param updates - The new values to update the object with.
@@ -1,6 +1,6 @@
1
1
  /**
2
- * Updates an object with a new set of values. undefined values are ignored in the updates object
3
- * and deep equal values are not updated.
2
+ * Updates an object with a new set of values. undefined values are ignored in
3
+ * the updates object and deep equal values are not updated.
4
4
  *
5
5
  * @param object - The object to update.
6
6
  * @param updates - The new values to update the object with.
package/dist/objUtils.cjs CHANGED
@@ -20,15 +20,50 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
20
20
  // src/objUtils.ts
21
21
  var objUtils_exports = {};
22
22
  __export(objUtils_exports, {
23
+ filterObjectKeys: () => filterObjectKeys,
23
24
  looseGetObjectProperty: () => looseGetObjectProperty,
24
25
  mapArrayToObject: () => mapArrayToObject,
25
26
  mapObjectToObject: () => mapObjectToObject,
26
27
  objectTypedEntries: () => objectTypedEntries,
27
28
  omit: () => omit,
28
29
  pick: () => pick,
29
- rejectObjUndefinedValues: () => rejectObjUndefinedValues
30
+ rejectObjUndefinedValues: () => rejectObjUndefinedValues,
31
+ sortObjectKeys: () => sortObjectKeys
30
32
  });
31
33
  module.exports = __toCommonJS(objUtils_exports);
34
+
35
+ // src/arrayUtils.ts
36
+ function sortBy(arr, sortByValue, props = "asc") {
37
+ const order = Array.isArray(props) || typeof props === "string" ? props : props.order ?? "asc";
38
+ return [...arr].sort((a, b) => {
39
+ const _aPriority = sortByValue(a);
40
+ const _bPriority = sortByValue(b);
41
+ const aPriority = Array.isArray(_aPriority) ? _aPriority : [_aPriority];
42
+ const bPriority = Array.isArray(_bPriority) ? _bPriority : [_bPriority];
43
+ for (let i = 0; i < aPriority.length; i++) {
44
+ const levelOrder = typeof order === "string" ? order : order[i] ?? "asc";
45
+ const aP = aPriority[i] ?? 0;
46
+ const bP = bPriority[i] ?? 0;
47
+ if (aP === bP) {
48
+ continue;
49
+ }
50
+ if (bP === Infinity || aP === -Infinity || aP < bP) {
51
+ return levelOrder === "asc" ? -1 : 1;
52
+ }
53
+ if (aP === Infinity || bP === -Infinity || aP > bP) {
54
+ return levelOrder === "asc" ? 1 : -1;
55
+ }
56
+ }
57
+ return 0;
58
+ });
59
+ }
60
+
61
+ // src/typingFnUtils.ts
62
+ function typedObjectEntries(obj) {
63
+ return Object.entries(obj);
64
+ }
65
+
66
+ // src/objUtils.ts
32
67
  function objectTypedEntries(obj) {
33
68
  return Object.entries(obj);
34
69
  }
@@ -68,13 +103,27 @@ function rejectObjUndefinedValues(obj) {
68
103
  }
69
104
  return result;
70
105
  }
106
+ function filterObjectKeys(obj, predicate) {
107
+ return Object.fromEntries(
108
+ Object.entries(obj).filter(
109
+ ([key, value]) => predicate(key, value)
110
+ )
111
+ );
112
+ }
113
+ function sortObjectKeys(obj, sortByFn, options) {
114
+ return Object.fromEntries(
115
+ sortBy(typedObjectEntries(obj), sortByFn, options)
116
+ );
117
+ }
71
118
  // Annotate the CommonJS export names for ESM import in node:
72
119
  0 && (module.exports = {
120
+ filterObjectKeys,
73
121
  looseGetObjectProperty,
74
122
  mapArrayToObject,
75
123
  mapObjectToObject,
76
124
  objectTypedEntries,
77
125
  omit,
78
126
  pick,
79
- rejectObjUndefinedValues
127
+ rejectObjUndefinedValues,
128
+ sortObjectKeys
80
129
  });
@@ -1,6 +1,9 @@
1
+ import { SortByValueFn, SortByProps } from './arrayUtils.cjs';
2
+ import { MakeUndefinedKeysOptional } from './typeUtils.cjs';
3
+
1
4
  /**
5
+ * @deprecated Use typedObjectEntries from @ls-stack/utils/typingFnUtils instead
2
6
  * @param obj
3
- * @deprecated use typedObjectEntries from @ls-stack/utils/typingFnUtils instead
4
7
  */
5
8
  declare function objectTypedEntries<T extends Record<string, unknown>>(obj: T): [Extract<keyof T, string>, T[keyof T]][];
6
9
  declare function pick<T extends Record<string, unknown>, K extends keyof T>(obj: T, keys: K[]): Pick<T, K>;
@@ -8,6 +11,8 @@ declare function mapArrayToObject<T, K extends string, O>(array: T[], mapper: (i
8
11
  declare function mapObjectToObject<I extends Record<string | number | symbol, unknown>, K extends string | number | symbol, O>(obj: I, mapper: (key: keyof I, value: I[keyof I]) => [K, O]): Record<K, O>;
9
12
  declare function omit<T extends Record<string, unknown>, K extends keyof T>(obj: T, keys: K[]): Omit<T, K>;
10
13
  declare function looseGetObjectProperty<T extends Record<string, unknown>>(obj: T, key: string): T[keyof T] | undefined;
11
- declare function rejectObjUndefinedValues<T extends Record<string, unknown>>(obj: T): T;
14
+ declare function rejectObjUndefinedValues<T extends Record<string, unknown>>(obj: T): MakeUndefinedKeysOptional<T>;
15
+ declare function filterObjectKeys<T extends Record<string, unknown>>(obj: T, predicate: (key: keyof T, value: T[keyof T]) => boolean): Partial<T>;
16
+ declare function sortObjectKeys<T extends Record<string, unknown>>(obj: T, sortByFn: SortByValueFn<[key: keyof T, value: T[keyof T]]>, options?: SortByProps): T;
12
17
 
13
- export { looseGetObjectProperty, mapArrayToObject, mapObjectToObject, objectTypedEntries, omit, pick, rejectObjUndefinedValues };
18
+ export { filterObjectKeys, looseGetObjectProperty, mapArrayToObject, mapObjectToObject, objectTypedEntries, omit, pick, rejectObjUndefinedValues, sortObjectKeys };
@@ -1,6 +1,9 @@
1
+ import { SortByValueFn, SortByProps } from './arrayUtils.js';
2
+ import { MakeUndefinedKeysOptional } from './typeUtils.js';
3
+
1
4
  /**
5
+ * @deprecated Use typedObjectEntries from @ls-stack/utils/typingFnUtils instead
2
6
  * @param obj
3
- * @deprecated use typedObjectEntries from @ls-stack/utils/typingFnUtils instead
4
7
  */
5
8
  declare function objectTypedEntries<T extends Record<string, unknown>>(obj: T): [Extract<keyof T, string>, T[keyof T]][];
6
9
  declare function pick<T extends Record<string, unknown>, K extends keyof T>(obj: T, keys: K[]): Pick<T, K>;
@@ -8,6 +11,8 @@ declare function mapArrayToObject<T, K extends string, O>(array: T[], mapper: (i
8
11
  declare function mapObjectToObject<I extends Record<string | number | symbol, unknown>, K extends string | number | symbol, O>(obj: I, mapper: (key: keyof I, value: I[keyof I]) => [K, O]): Record<K, O>;
9
12
  declare function omit<T extends Record<string, unknown>, K extends keyof T>(obj: T, keys: K[]): Omit<T, K>;
10
13
  declare function looseGetObjectProperty<T extends Record<string, unknown>>(obj: T, key: string): T[keyof T] | undefined;
11
- declare function rejectObjUndefinedValues<T extends Record<string, unknown>>(obj: T): T;
14
+ declare function rejectObjUndefinedValues<T extends Record<string, unknown>>(obj: T): MakeUndefinedKeysOptional<T>;
15
+ declare function filterObjectKeys<T extends Record<string, unknown>>(obj: T, predicate: (key: keyof T, value: T[keyof T]) => boolean): Partial<T>;
16
+ declare function sortObjectKeys<T extends Record<string, unknown>>(obj: T, sortByFn: SortByValueFn<[key: keyof T, value: T[keyof T]]>, options?: SortByProps): T;
12
17
 
13
- export { looseGetObjectProperty, mapArrayToObject, mapObjectToObject, objectTypedEntries, omit, pick, rejectObjUndefinedValues };
18
+ export { filterObjectKeys, looseGetObjectProperty, mapArrayToObject, mapObjectToObject, objectTypedEntries, omit, pick, rejectObjUndefinedValues, sortObjectKeys };
package/dist/objUtils.js CHANGED
@@ -1,18 +1,26 @@
1
1
  import {
2
+ filterObjectKeys,
2
3
  looseGetObjectProperty,
3
4
  mapArrayToObject,
4
5
  mapObjectToObject,
5
6
  objectTypedEntries,
6
7
  omit,
7
8
  pick,
8
- rejectObjUndefinedValues
9
- } from "./chunk-GHAQOUA6.js";
9
+ rejectObjUndefinedValues,
10
+ sortObjectKeys
11
+ } from "./chunk-23KPGKDT.js";
12
+ import "./chunk-DTE2QMWE.js";
13
+ import "./chunk-27AL66CH.js";
14
+ import "./chunk-C2SVCIWE.js";
15
+ import "./chunk-JF2MDHOJ.js";
10
16
  export {
17
+ filterObjectKeys,
11
18
  looseGetObjectProperty,
12
19
  mapArrayToObject,
13
20
  mapObjectToObject,
14
21
  objectTypedEntries,
15
22
  omit,
16
23
  pick,
17
- rejectObjUndefinedValues
24
+ rejectObjUndefinedValues,
25
+ sortObjectKeys
18
26
  };
@@ -56,7 +56,8 @@ var ParallelAsyncResultCalls = class {
56
56
  return this;
57
57
  }
58
58
  /**
59
- * adds calls return tuples with inferred results
59
+ * Adds calls return tuples with inferred results
60
+ *
60
61
  * @param calls
61
62
  */
62
63
  addTuple(...calls) {
@@ -38,7 +38,8 @@ declare class ParallelAsyncResultCalls<M extends ValidMetadata | undefined = und
38
38
  fn: () => Promise<Result<R>>;
39
39
  }): this;
40
40
  /**
41
- * adds calls return tuples with inferred results
41
+ * Adds calls return tuples with inferred results
42
+ *
42
43
  * @param calls
43
44
  */
44
45
  addTuple<T extends (M extends undefined ? () => Promise<Result<R>> : {
@@ -69,12 +70,12 @@ declare class ParallelAsyncResultCalls<M extends ValidMetadata | undefined = und
69
70
  }>>;
70
71
  }
71
72
  /**
72
- * Executes multiple asynchronous calls in parallel and collects the results in a easier to use format.
73
+ * Executes multiple asynchronous calls in parallel and collects the results in
74
+ * a easier to use format.
73
75
  *
76
+ * @deprecated Use concurrentAsyncCalls instead.
74
77
  * @template R - The type of the result value.
75
78
  * @template M - The type of the call metadata.
76
- *
77
- * @deprecated Use concurrentAsyncCalls instead.
78
79
  */
79
80
  declare function parallelAsyncCalls<M extends ValidMetadata | undefined = undefined, R = unknown>(): ParallelAsyncResultCalls<M, R>;
80
81
 
@@ -38,7 +38,8 @@ declare class ParallelAsyncResultCalls<M extends ValidMetadata | undefined = und
38
38
  fn: () => Promise<Result<R>>;
39
39
  }): this;
40
40
  /**
41
- * adds calls return tuples with inferred results
41
+ * Adds calls return tuples with inferred results
42
+ *
42
43
  * @param calls
43
44
  */
44
45
  addTuple<T extends (M extends undefined ? () => Promise<Result<R>> : {
@@ -69,12 +70,12 @@ declare class ParallelAsyncResultCalls<M extends ValidMetadata | undefined = und
69
70
  }>>;
70
71
  }
71
72
  /**
72
- * Executes multiple asynchronous calls in parallel and collects the results in a easier to use format.
73
+ * Executes multiple asynchronous calls in parallel and collects the results in
74
+ * a easier to use format.
73
75
  *
76
+ * @deprecated Use concurrentAsyncCalls instead.
74
77
  * @template R - The type of the result value.
75
78
  * @template M - The type of the call metadata.
76
- *
77
- * @deprecated Use concurrentAsyncCalls instead.
78
79
  */
79
80
  declare function parallelAsyncCalls<M extends ValidMetadata | undefined = undefined, R = unknown>(): ParallelAsyncResultCalls<M, R>;
80
81
 
@@ -21,7 +21,8 @@ var ParallelAsyncResultCalls = class {
21
21
  return this;
22
22
  }
23
23
  /**
24
- * adds calls return tuples with inferred results
24
+ * Adds calls return tuples with inferred results
25
+ *
25
26
  * @param calls
26
27
  */
27
28
  addTuple(...calls) {