@ls-stack/utils 3.33.0 → 3.34.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 (206) hide show
  1. package/{lib → dist}/arrayUtils.cjs +5 -0
  2. package/{lib → dist}/arrayUtils.d.cts +19 -1
  3. package/{lib → dist}/arrayUtils.d.ts +19 -1
  4. package/{lib → dist}/arrayUtils.js +3 -1
  5. package/{lib/chunk-RYBJST64.js → dist/chunk-4DVTWCXL.js} +4 -0
  6. package/{lib/chunk-IY3KYH32.js → dist/chunk-ADM37GSC.js} +1 -1
  7. package/{lib/chunk-3LZQMZAS.js → dist/chunk-KW55OTUG.js} +5 -1
  8. package/{lib/chunk-XUNY3QUT.js → dist/chunk-XPOGWCUC.js} +1 -1
  9. package/{lib → dist}/concurrentCalls.js +2 -2
  10. package/{lib → dist}/filterObjectOrArrayKeys.js +2 -2
  11. package/{lib → dist}/serializeXML.js +1 -1
  12. package/{lib → dist}/stringUtils.cjs +5 -0
  13. package/{lib → dist}/stringUtils.d.cts +2 -1
  14. package/{lib → dist}/stringUtils.d.ts +2 -1
  15. package/{lib → dist}/stringUtils.js +3 -1
  16. package/{lib → dist}/testUtils.js +4 -4
  17. package/{lib → dist}/yamlStringify.js +2 -2
  18. package/docs/arrayUtils/-internal-.md +4 -4
  19. package/docs/arrayUtils/README.md +45 -10
  20. package/docs/stringUtils/README.md +20 -0
  21. package/package.json +2 -2
  22. /package/{lib → dist}/assertions.cjs +0 -0
  23. /package/{lib → dist}/assertions.d.cts +0 -0
  24. /package/{lib → dist}/assertions.d.ts +0 -0
  25. /package/{lib → dist}/assertions.js +0 -0
  26. /package/{lib → dist}/asyncQueue.cjs +0 -0
  27. /package/{lib → dist}/asyncQueue.d.cts +0 -0
  28. /package/{lib → dist}/asyncQueue.d.ts +0 -0
  29. /package/{lib → dist}/asyncQueue.js +0 -0
  30. /package/{lib → dist}/awaitDebounce.cjs +0 -0
  31. /package/{lib → dist}/awaitDebounce.d.cts +0 -0
  32. /package/{lib → dist}/awaitDebounce.d.ts +0 -0
  33. /package/{lib → dist}/awaitDebounce.js +0 -0
  34. /package/{lib → dist}/cache.cjs +0 -0
  35. /package/{lib → dist}/cache.d.cts +0 -0
  36. /package/{lib → dist}/cache.d.ts +0 -0
  37. /package/{lib → dist}/cache.js +0 -0
  38. /package/{lib → dist}/castValues.cjs +0 -0
  39. /package/{lib → dist}/castValues.d.cts +0 -0
  40. /package/{lib → dist}/castValues.d.ts +0 -0
  41. /package/{lib → dist}/castValues.js +0 -0
  42. /package/{lib → dist}/chunk-5DZT3Z5Z.js +0 -0
  43. /package/{lib → dist}/chunk-5MNYPLZI.js +0 -0
  44. /package/{lib → dist}/chunk-6FIBVC2P.js +0 -0
  45. /package/{lib → dist}/chunk-7CQPOM5I.js +0 -0
  46. /package/{lib → dist}/chunk-C2SVCIWE.js +0 -0
  47. /package/{lib → dist}/chunk-DFXNVEH6.js +0 -0
  48. /package/{lib → dist}/chunk-GHAQOUA6.js +0 -0
  49. /package/{lib → dist}/chunk-HTCYUMDR.js +0 -0
  50. /package/{lib → dist}/chunk-IATIXMCE.js +0 -0
  51. /package/{lib → dist}/chunk-II4R3VVX.js +0 -0
  52. /package/{lib → dist}/chunk-JF2MDHOJ.js +0 -0
  53. /package/{lib → dist}/chunk-JQFUKJU5.js +0 -0
  54. /package/{lib → dist}/chunk-NW5H5EW7.js +0 -0
  55. /package/{lib → dist}/chunk-VAAMRG4K.js +0 -0
  56. /package/{lib → dist}/concurrentCalls.cjs +0 -0
  57. /package/{lib → dist}/concurrentCalls.d.cts +0 -0
  58. /package/{lib → dist}/concurrentCalls.d.ts +0 -0
  59. /package/{lib → dist}/consoleFmt.cjs +0 -0
  60. /package/{lib → dist}/consoleFmt.d.cts +0 -0
  61. /package/{lib → dist}/consoleFmt.d.ts +0 -0
  62. /package/{lib → dist}/consoleFmt.js +0 -0
  63. /package/{lib → dist}/conversions.cjs +0 -0
  64. /package/{lib → dist}/conversions.d.cts +0 -0
  65. /package/{lib → dist}/conversions.d.ts +0 -0
  66. /package/{lib → dist}/conversions.js +0 -0
  67. /package/{lib → dist}/createThrottleController.cjs +0 -0
  68. /package/{lib → dist}/createThrottleController.d.cts +0 -0
  69. /package/{lib → dist}/createThrottleController.d.ts +0 -0
  70. /package/{lib → dist}/createThrottleController.js +0 -0
  71. /package/{lib → dist}/debounce.cjs +0 -0
  72. /package/{lib → dist}/debounce.d.cts +0 -0
  73. /package/{lib → dist}/debounce.d.ts +0 -0
  74. /package/{lib → dist}/debounce.js +0 -0
  75. /package/{lib → dist}/dedent.cjs +0 -0
  76. /package/{lib → dist}/dedent.d.cts +0 -0
  77. /package/{lib → dist}/dedent.d.ts +0 -0
  78. /package/{lib → dist}/dedent.js +0 -0
  79. /package/{lib → dist}/deepEqual.cjs +0 -0
  80. /package/{lib → dist}/deepEqual.d.cts +0 -0
  81. /package/{lib → dist}/deepEqual.d.ts +0 -0
  82. /package/{lib → dist}/deepEqual.js +0 -0
  83. /package/{lib → dist}/enhancedMap.cjs +0 -0
  84. /package/{lib → dist}/enhancedMap.d.cts +0 -0
  85. /package/{lib → dist}/enhancedMap.d.ts +0 -0
  86. /package/{lib → dist}/enhancedMap.js +0 -0
  87. /package/{lib → dist}/exhaustiveMatch.cjs +0 -0
  88. /package/{lib → dist}/exhaustiveMatch.d.cts +0 -0
  89. /package/{lib → dist}/exhaustiveMatch.d.ts +0 -0
  90. /package/{lib → dist}/exhaustiveMatch.js +0 -0
  91. /package/{lib → dist}/filterObjectOrArrayKeys.cjs +0 -0
  92. /package/{lib → dist}/filterObjectOrArrayKeys.d.cts +0 -0
  93. /package/{lib → dist}/filterObjectOrArrayKeys.d.ts +0 -0
  94. /package/{lib → dist}/getAutoIncrementId.cjs +0 -0
  95. /package/{lib → dist}/getAutoIncrementId.d.cts +0 -0
  96. /package/{lib → dist}/getAutoIncrementId.d.ts +0 -0
  97. /package/{lib → dist}/getAutoIncrementId.js +0 -0
  98. /package/{lib → dist}/getCompositeKey.cjs +0 -0
  99. /package/{lib → dist}/getCompositeKey.d.cts +0 -0
  100. /package/{lib → dist}/getCompositeKey.d.ts +0 -0
  101. /package/{lib → dist}/getCompositeKey.js +0 -0
  102. /package/{lib → dist}/getValueStableKey.cjs +0 -0
  103. /package/{lib → dist}/getValueStableKey.d.cts +0 -0
  104. /package/{lib → dist}/getValueStableKey.d.ts +0 -0
  105. /package/{lib → dist}/getValueStableKey.js +0 -0
  106. /package/{lib → dist}/hash.cjs +0 -0
  107. /package/{lib → dist}/hash.d.cts +0 -0
  108. /package/{lib → dist}/hash.d.ts +0 -0
  109. /package/{lib → dist}/hash.js +0 -0
  110. /package/{lib → dist}/interpolate.cjs +0 -0
  111. /package/{lib → dist}/interpolate.d.cts +0 -0
  112. /package/{lib → dist}/interpolate.d.ts +0 -0
  113. /package/{lib → dist}/interpolate.js +0 -0
  114. /package/{lib → dist}/levenshtein.cjs +0 -0
  115. /package/{lib → dist}/levenshtein.d.cts +0 -0
  116. /package/{lib → dist}/levenshtein.d.ts +0 -0
  117. /package/{lib → dist}/levenshtein.js +0 -0
  118. /package/{lib → dist}/main.cjs +0 -0
  119. /package/{lib → dist}/main.d.cts +0 -0
  120. /package/{lib → dist}/main.d.ts +0 -0
  121. /package/{lib → dist}/main.js +0 -0
  122. /package/{lib → dist}/mathUtils.cjs +0 -0
  123. /package/{lib → dist}/mathUtils.d.cts +0 -0
  124. /package/{lib → dist}/mathUtils.d.ts +0 -0
  125. /package/{lib → dist}/mathUtils.js +0 -0
  126. /package/{lib → dist}/objUtils.cjs +0 -0
  127. /package/{lib → dist}/objUtils.d.cts +0 -0
  128. /package/{lib → dist}/objUtils.d.ts +0 -0
  129. /package/{lib → dist}/objUtils.js +0 -0
  130. /package/{lib → dist}/parallelAsyncCalls.cjs +0 -0
  131. /package/{lib → dist}/parallelAsyncCalls.d.cts +0 -0
  132. /package/{lib → dist}/parallelAsyncCalls.d.ts +0 -0
  133. /package/{lib → dist}/parallelAsyncCalls.js +0 -0
  134. /package/{lib → dist}/promiseUtils.cjs +0 -0
  135. /package/{lib → dist}/promiseUtils.d.cts +0 -0
  136. /package/{lib → dist}/promiseUtils.d.ts +0 -0
  137. /package/{lib → dist}/promiseUtils.js +0 -0
  138. /package/{lib → dist}/retryOnError.cjs +0 -0
  139. /package/{lib → dist}/retryOnError.d.cts +0 -0
  140. /package/{lib → dist}/retryOnError.d.ts +0 -0
  141. /package/{lib → dist}/retryOnError.js +0 -0
  142. /package/{lib → dist}/runShellCmd.cjs +0 -0
  143. /package/{lib → dist}/runShellCmd.d.cts +0 -0
  144. /package/{lib → dist}/runShellCmd.d.ts +0 -0
  145. /package/{lib → dist}/runShellCmd.js +0 -0
  146. /package/{lib → dist}/safeJson.cjs +0 -0
  147. /package/{lib → dist}/safeJson.d.cts +0 -0
  148. /package/{lib → dist}/safeJson.d.ts +0 -0
  149. /package/{lib → dist}/safeJson.js +0 -0
  150. /package/{lib → dist}/saferTyping.cjs +0 -0
  151. /package/{lib → dist}/saferTyping.d.cts +0 -0
  152. /package/{lib → dist}/saferTyping.d.ts +0 -0
  153. /package/{lib → dist}/saferTyping.js +0 -0
  154. /package/{lib → dist}/serializeXML.cjs +0 -0
  155. /package/{lib → dist}/serializeXML.d.cts +0 -0
  156. /package/{lib → dist}/serializeXML.d.ts +0 -0
  157. /package/{lib → dist}/shallowEqual.cjs +0 -0
  158. /package/{lib → dist}/shallowEqual.d.cts +0 -0
  159. /package/{lib → dist}/shallowEqual.d.ts +0 -0
  160. /package/{lib → dist}/shallowEqual.js +0 -0
  161. /package/{lib → dist}/sleep.cjs +0 -0
  162. /package/{lib → dist}/sleep.d.cts +0 -0
  163. /package/{lib → dist}/sleep.d.ts +0 -0
  164. /package/{lib → dist}/sleep.js +0 -0
  165. /package/{lib → dist}/testUtils.cjs +0 -0
  166. /package/{lib → dist}/testUtils.d.cts +0 -0
  167. /package/{lib → dist}/testUtils.d.ts +0 -0
  168. /package/{lib → dist}/throttle.cjs +0 -0
  169. /package/{lib → dist}/throttle.d.cts +0 -0
  170. /package/{lib → dist}/throttle.d.ts +0 -0
  171. /package/{lib → dist}/throttle.js +0 -0
  172. /package/{lib → dist}/time.cjs +0 -0
  173. /package/{lib → dist}/time.d.cts +0 -0
  174. /package/{lib → dist}/time.d.ts +0 -0
  175. /package/{lib → dist}/time.js +0 -0
  176. /package/{lib → dist}/timers.cjs +0 -0
  177. /package/{lib → dist}/timers.d.cts +0 -0
  178. /package/{lib → dist}/timers.d.ts +0 -0
  179. /package/{lib → dist}/timers.js +0 -0
  180. /package/{lib → dist}/tsResult.cjs +0 -0
  181. /package/{lib → dist}/tsResult.d.cts +0 -0
  182. /package/{lib → dist}/tsResult.d.ts +0 -0
  183. /package/{lib → dist}/tsResult.js +0 -0
  184. /package/{lib → dist}/typeGuards.cjs +0 -0
  185. /package/{lib → dist}/typeGuards.d.cts +0 -0
  186. /package/{lib → dist}/typeGuards.d.ts +0 -0
  187. /package/{lib → dist}/typeGuards.js +0 -0
  188. /package/{lib → dist}/typeUtils.cjs +0 -0
  189. /package/{lib → dist}/typeUtils.d.cts +0 -0
  190. /package/{lib → dist}/typeUtils.d.ts +0 -0
  191. /package/{lib → dist}/typeUtils.js +0 -0
  192. /package/{lib → dist}/typingFnUtils.cjs +0 -0
  193. /package/{lib → dist}/typingFnUtils.d.cts +0 -0
  194. /package/{lib → dist}/typingFnUtils.d.ts +0 -0
  195. /package/{lib → dist}/typingFnUtils.js +0 -0
  196. /package/{lib → dist}/typingTestUtils.cjs +0 -0
  197. /package/{lib → dist}/typingTestUtils.d.cts +0 -0
  198. /package/{lib → dist}/typingTestUtils.d.ts +0 -0
  199. /package/{lib → dist}/typingTestUtils.js +0 -0
  200. /package/{lib → dist}/typingUtils.cjs +0 -0
  201. /package/{lib → dist}/typingUtils.d.cts +0 -0
  202. /package/{lib → dist}/typingUtils.d.ts +0 -0
  203. /package/{lib → dist}/typingUtils.js +0 -0
  204. /package/{lib → dist}/yamlStringify.cjs +0 -0
  205. /package/{lib → dist}/yamlStringify.d.cts +0 -0
  206. /package/{lib → dist}/yamlStringify.d.ts +0 -0
@@ -26,6 +26,7 @@ __export(arrayUtils_exports, {
26
26
  filterAndMap: () => filterAndMap,
27
27
  findAfterIndex: () => findAfterIndex,
28
28
  findBeforeIndex: () => findBeforeIndex,
29
+ getAscIndexOrder: () => getAscIndexOrder,
29
30
  hasDuplicates: () => hasDuplicates,
30
31
  isInArray: () => isInArray,
31
32
  rejectArrayUndefinedValues: () => rejectArrayUndefinedValues,
@@ -80,6 +81,9 @@ function sortBy(arr, sortByValue, props = "asc") {
80
81
  return 0;
81
82
  });
82
83
  }
84
+ function getAscIndexOrder(index) {
85
+ return index === -1 ? Infinity : index ?? Infinity;
86
+ }
83
87
  function arrayWithPrev(array) {
84
88
  return array.map((item, i) => [item, array[i - 1] ?? null]);
85
89
  }
@@ -171,6 +175,7 @@ function arrayOps(array) {
171
175
  filterAndMap,
172
176
  findAfterIndex,
173
177
  findBeforeIndex,
178
+ getAscIndexOrder,
174
179
  hasDuplicates,
175
180
  isInArray,
176
181
  rejectArrayUndefinedValues,
@@ -47,6 +47,24 @@ type SortByProps = {
47
47
  * const sortedItems = sortBy(items, (item) => [item.a, item.b]);
48
48
  */
49
49
  declare function sortBy<T>(arr: T[], sortByValue: SortByValue<T>, props?: SortByProps): T[];
50
+ /**
51
+ * Get the correct 0 based value for sync with other array in ascending order
52
+ *
53
+ * @param index
54
+ *
55
+ * @example
56
+ * ```ts
57
+ * const items = [1, 2, 3];
58
+ *
59
+ * const index = sortBy(
60
+ * items,
61
+ * (item) => getAscIndexOrder(
62
+ * followOrder.findIndex((order) => order === item)
63
+ * )
64
+ * );
65
+ * ```
66
+ */
67
+ declare function getAscIndexOrder(index: number | undefined): number;
50
68
  declare function arrayWithPrev<T>(array: T[]): [current: T, prev: T | null][];
51
69
  declare function arrayWithPrevAndIndex<T>(array: T[]): {
52
70
  item: T;
@@ -91,4 +109,4 @@ type ArrayOps<T> = {
91
109
  */
92
110
  declare function arrayOps<T>(array: T[]): ArrayOps<T>;
93
111
 
94
- export { type FilterAndMapReturn, arrayOps, arrayWithPrev, arrayWithPrevAndIndex, filterAndMap, findAfterIndex, findBeforeIndex, hasDuplicates, isInArray, rejectArrayUndefinedValues, rejectDuplicates, sortBy, truncateArray };
112
+ export { type FilterAndMapReturn, arrayOps, arrayWithPrev, arrayWithPrevAndIndex, filterAndMap, findAfterIndex, findBeforeIndex, getAscIndexOrder, hasDuplicates, isInArray, rejectArrayUndefinedValues, rejectDuplicates, sortBy, truncateArray };
@@ -47,6 +47,24 @@ type SortByProps = {
47
47
  * const sortedItems = sortBy(items, (item) => [item.a, item.b]);
48
48
  */
49
49
  declare function sortBy<T>(arr: T[], sortByValue: SortByValue<T>, props?: SortByProps): T[];
50
+ /**
51
+ * Get the correct 0 based value for sync with other array in ascending order
52
+ *
53
+ * @param index
54
+ *
55
+ * @example
56
+ * ```ts
57
+ * const items = [1, 2, 3];
58
+ *
59
+ * const index = sortBy(
60
+ * items,
61
+ * (item) => getAscIndexOrder(
62
+ * followOrder.findIndex((order) => order === item)
63
+ * )
64
+ * );
65
+ * ```
66
+ */
67
+ declare function getAscIndexOrder(index: number | undefined): number;
50
68
  declare function arrayWithPrev<T>(array: T[]): [current: T, prev: T | null][];
51
69
  declare function arrayWithPrevAndIndex<T>(array: T[]): {
52
70
  item: T;
@@ -91,4 +109,4 @@ type ArrayOps<T> = {
91
109
  */
92
110
  declare function arrayOps<T>(array: T[]): ArrayOps<T>;
93
111
 
94
- export { type FilterAndMapReturn, arrayOps, arrayWithPrev, arrayWithPrevAndIndex, filterAndMap, findAfterIndex, findBeforeIndex, hasDuplicates, isInArray, rejectArrayUndefinedValues, rejectDuplicates, sortBy, truncateArray };
112
+ export { type FilterAndMapReturn, arrayOps, arrayWithPrev, arrayWithPrevAndIndex, filterAndMap, findAfterIndex, findBeforeIndex, getAscIndexOrder, hasDuplicates, isInArray, rejectArrayUndefinedValues, rejectDuplicates, sortBy, truncateArray };
@@ -5,13 +5,14 @@ import {
5
5
  filterAndMap,
6
6
  findAfterIndex,
7
7
  findBeforeIndex,
8
+ getAscIndexOrder,
8
9
  hasDuplicates,
9
10
  isInArray,
10
11
  rejectArrayUndefinedValues,
11
12
  rejectDuplicates,
12
13
  sortBy,
13
14
  truncateArray
14
- } from "./chunk-RYBJST64.js";
15
+ } from "./chunk-4DVTWCXL.js";
15
16
  import "./chunk-C2SVCIWE.js";
16
17
  import "./chunk-JF2MDHOJ.js";
17
18
  export {
@@ -21,6 +22,7 @@ export {
21
22
  filterAndMap,
22
23
  findAfterIndex,
23
24
  findBeforeIndex,
25
+ getAscIndexOrder,
24
26
  hasDuplicates,
25
27
  isInArray,
26
28
  rejectArrayUndefinedValues,
@@ -39,6 +39,9 @@ function sortBy(arr, sortByValue, props = "asc") {
39
39
  return 0;
40
40
  });
41
41
  }
42
+ function getAscIndexOrder(index) {
43
+ return index === -1 ? Infinity : index ?? Infinity;
44
+ }
42
45
  function arrayWithPrev(array) {
43
46
  return array.map((item, i) => [item, array[i - 1] ?? null]);
44
47
  }
@@ -126,6 +129,7 @@ function arrayOps(array) {
126
129
  export {
127
130
  filterAndMap,
128
131
  sortBy,
132
+ getAscIndexOrder,
129
133
  arrayWithPrev,
130
134
  arrayWithPrevAndIndex,
131
135
  isInArray,
@@ -3,7 +3,7 @@ import {
3
3
  } from "./chunk-IATIXMCE.js";
4
4
  import {
5
5
  truncateString
6
- } from "./chunk-3LZQMZAS.js";
6
+ } from "./chunk-KW55OTUG.js";
7
7
  import {
8
8
  isObject,
9
9
  isPlainObject
@@ -42,6 +42,9 @@ function truncateString(str, length, ellipsis = "\u2026") {
42
42
  if (str.length <= length) return str;
43
43
  return str.slice(0, length - 1) + ellipsis;
44
44
  }
45
+ function removeANSIColors(str) {
46
+ return str.replace(/\u001b\[\d+m/g, "");
47
+ }
45
48
 
46
49
  export {
47
50
  concatStrings,
@@ -53,5 +56,6 @@ export {
53
56
  convertToCamelCase,
54
57
  convertToSentenceCase,
55
58
  convertToTitleCase,
56
- truncateString
59
+ truncateString,
60
+ removeANSIColors
57
61
  };
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  sortBy
3
- } from "./chunk-RYBJST64.js";
3
+ } from "./chunk-4DVTWCXL.js";
4
4
  import {
5
5
  isPlainObject
6
6
  } from "./chunk-JF2MDHOJ.js";
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  truncateString
3
- } from "./chunk-3LZQMZAS.js";
3
+ } from "./chunk-KW55OTUG.js";
4
4
  import {
5
5
  sleep
6
6
  } from "./chunk-5DZT3Z5Z.js";
@@ -9,7 +9,7 @@ import {
9
9
  } from "./chunk-VAAMRG4K.js";
10
10
  import {
11
11
  truncateArray
12
- } from "./chunk-RYBJST64.js";
12
+ } from "./chunk-4DVTWCXL.js";
13
13
  import {
14
14
  invariant
15
15
  } from "./chunk-C2SVCIWE.js";
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  filterObjectOrArrayKeys
3
- } from "./chunk-XUNY3QUT.js";
4
- import "./chunk-RYBJST64.js";
3
+ } from "./chunk-XPOGWCUC.js";
4
+ import "./chunk-4DVTWCXL.js";
5
5
  import "./chunk-C2SVCIWE.js";
6
6
  import "./chunk-JF2MDHOJ.js";
7
7
  export {
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  filterAndMap
3
- } from "./chunk-RYBJST64.js";
3
+ } from "./chunk-4DVTWCXL.js";
4
4
  import "./chunk-C2SVCIWE.js";
5
5
  import {
6
6
  isTruthy
@@ -29,6 +29,7 @@ __export(stringUtils_exports, {
29
29
  formatNum: () => formatNum,
30
30
  isSnakeCase: () => isSnakeCase,
31
31
  joinStrings: () => joinStrings,
32
+ removeANSIColors: () => removeANSIColors,
32
33
  truncateString: () => truncateString
33
34
  });
34
35
  module.exports = __toCommonJS(stringUtils_exports);
@@ -75,6 +76,9 @@ function truncateString(str, length, ellipsis = "\u2026") {
75
76
  if (str.length <= length) return str;
76
77
  return str.slice(0, length - 1) + ellipsis;
77
78
  }
79
+ function removeANSIColors(str) {
80
+ return str.replace(/\u001b\[\d+m/g, "");
81
+ }
78
82
  // Annotate the CommonJS export names for ESM import in node:
79
83
  0 && (module.exports = {
80
84
  concatStrings,
@@ -86,5 +90,6 @@ function truncateString(str, length, ellipsis = "\u2026") {
86
90
  formatNum,
87
91
  isSnakeCase,
88
92
  joinStrings,
93
+ removeANSIColors,
89
94
  truncateString
90
95
  });
@@ -21,5 +21,6 @@ declare function convertToCamelCase(str: string): string;
21
21
  declare function convertToSentenceCase(str: string): string;
22
22
  declare function convertToTitleCase(str: string): string;
23
23
  declare function truncateString(str: string, length: number, ellipsis?: string): string;
24
+ declare function removeANSIColors(str: string): string;
24
25
 
25
- export { concatStrings, convertToCamelCase, convertToPascalCase, convertToSentenceCase, convertToSnakeCase, convertToTitleCase, formatNum, isSnakeCase, joinStrings, truncateString };
26
+ export { concatStrings, convertToCamelCase, convertToPascalCase, convertToSentenceCase, convertToSnakeCase, convertToTitleCase, formatNum, isSnakeCase, joinStrings, removeANSIColors, truncateString };
@@ -21,5 +21,6 @@ declare function convertToCamelCase(str: string): string;
21
21
  declare function convertToSentenceCase(str: string): string;
22
22
  declare function convertToTitleCase(str: string): string;
23
23
  declare function truncateString(str: string, length: number, ellipsis?: string): string;
24
+ declare function removeANSIColors(str: string): string;
24
25
 
25
- export { concatStrings, convertToCamelCase, convertToPascalCase, convertToSentenceCase, convertToSnakeCase, convertToTitleCase, formatNum, isSnakeCase, joinStrings, truncateString };
26
+ export { concatStrings, convertToCamelCase, convertToPascalCase, convertToSentenceCase, convertToSnakeCase, convertToTitleCase, formatNum, isSnakeCase, joinStrings, removeANSIColors, truncateString };
@@ -8,8 +8,9 @@ import {
8
8
  formatNum,
9
9
  isSnakeCase,
10
10
  joinStrings,
11
+ removeANSIColors,
11
12
  truncateString
12
- } from "./chunk-3LZQMZAS.js";
13
+ } from "./chunk-KW55OTUG.js";
13
14
  export {
14
15
  concatStrings,
15
16
  convertToCamelCase,
@@ -20,5 +21,6 @@ export {
20
21
  formatNum,
21
22
  isSnakeCase,
22
23
  joinStrings,
24
+ removeANSIColors,
23
25
  truncateString
24
26
  };
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  yamlStringify
3
- } from "./chunk-IY3KYH32.js";
3
+ } from "./chunk-ADM37GSC.js";
4
4
  import {
5
5
  omit,
6
6
  pick
@@ -11,18 +11,18 @@ import {
11
11
  } from "./chunk-JQFUKJU5.js";
12
12
  import {
13
13
  filterObjectOrArrayKeys
14
- } from "./chunk-XUNY3QUT.js";
14
+ } from "./chunk-XPOGWCUC.js";
15
15
  import {
16
16
  defer
17
17
  } from "./chunk-DFXNVEH6.js";
18
18
  import {
19
19
  clampMin
20
20
  } from "./chunk-HTCYUMDR.js";
21
- import "./chunk-3LZQMZAS.js";
21
+ import "./chunk-KW55OTUG.js";
22
22
  import {
23
23
  arrayWithPrevAndIndex,
24
24
  filterAndMap
25
- } from "./chunk-RYBJST64.js";
25
+ } from "./chunk-4DVTWCXL.js";
26
26
  import {
27
27
  isObject
28
28
  } from "./chunk-C2SVCIWE.js";
@@ -1,8 +1,8 @@
1
1
  import {
2
2
  yamlStringify
3
- } from "./chunk-IY3KYH32.js";
3
+ } from "./chunk-ADM37GSC.js";
4
4
  import "./chunk-IATIXMCE.js";
5
- import "./chunk-3LZQMZAS.js";
5
+ import "./chunk-KW55OTUG.js";
6
6
  import "./chunk-JF2MDHOJ.js";
7
7
  export {
8
8
  yamlStringify
@@ -14,7 +14,7 @@
14
14
  type ArrayOps<T> = object;
15
15
  ```
16
16
 
17
- Defined in: [packages/utils/src/arrayUtils.ts:238](https://github.com/lucasols/utils/blob/main/packages/utils/src/arrayUtils.ts#L238)
17
+ Defined in: [packages/utils/src/arrayUtils.ts:259](https://github.com/lucasols/utils/blob/main/packages/utils/src/arrayUtils.ts#L259)
18
18
 
19
19
  #### Type Parameters
20
20
 
@@ -30,7 +30,7 @@ Defined in: [packages/utils/src/arrayUtils.ts:238](https://github.com/lucasols/u
30
30
  filterAndMap: <R>(mapFilter) => R[];
31
31
  ```
32
32
 
33
- Defined in: [packages/utils/src/arrayUtils.ts:251](https://github.com/lucasols/utils/blob/main/packages/utils/src/arrayUtils.ts#L251)
33
+ Defined in: [packages/utils/src/arrayUtils.ts:272](https://github.com/lucasols/utils/blob/main/packages/utils/src/arrayUtils.ts#L272)
34
34
 
35
35
  Filter and map an array
36
36
 
@@ -69,7 +69,7 @@ enhancedItems.filterAndMap((item) => item === 2 ? false : item);
69
69
  rejectDuplicates: (getKey) => T[];
70
70
  ```
71
71
 
72
- Defined in: [packages/utils/src/arrayUtils.ts:253](https://github.com/lucasols/utils/blob/main/packages/utils/src/arrayUtils.ts#L253)
72
+ Defined in: [packages/utils/src/arrayUtils.ts:274](https://github.com/lucasols/utils/blob/main/packages/utils/src/arrayUtils.ts#L274)
73
73
 
74
74
  ###### Parameters
75
75
 
@@ -87,7 +87,7 @@ Defined in: [packages/utils/src/arrayUtils.ts:253](https://github.com/lucasols/u
87
87
  sortBy: (sortByValue, props) => T[];
88
88
  ```
89
89
 
90
- Defined in: [packages/utils/src/arrayUtils.ts:252](https://github.com/lucasols/utils/blob/main/packages/utils/src/arrayUtils.ts#L252)
90
+ Defined in: [packages/utils/src/arrayUtils.ts:273](https://github.com/lucasols/utils/blob/main/packages/utils/src/arrayUtils.ts#L273)
91
91
 
92
92
  ###### Parameters
93
93
 
@@ -34,7 +34,7 @@ Defined in: [packages/utils/src/arrayUtils.ts:42](https://github.com/lucasols/ut
34
34
  function arrayOps<T>(array): ArrayOps<T>;
35
35
  ```
36
36
 
37
- Defined in: [packages/utils/src/arrayUtils.ts:268](https://github.com/lucasols/utils/blob/main/packages/utils/src/arrayUtils.ts#L268)
37
+ Defined in: [packages/utils/src/arrayUtils.ts:289](https://github.com/lucasols/utils/blob/main/packages/utils/src/arrayUtils.ts#L289)
38
38
 
39
39
  Enhance an array with extra methods
40
40
 
@@ -72,7 +72,7 @@ enhancedItems.rejectDuplicates((item) => item);
72
72
  function arrayWithPrev<T>(array): [T, null | T][];
73
73
  ```
74
74
 
75
- Defined in: [packages/utils/src/arrayUtils.ts:117](https://github.com/lucasols/utils/blob/main/packages/utils/src/arrayUtils.ts#L117)
75
+ Defined in: [packages/utils/src/arrayUtils.ts:138](https://github.com/lucasols/utils/blob/main/packages/utils/src/arrayUtils.ts#L138)
76
76
 
77
77
  #### Type Parameters
78
78
 
@@ -98,7 +98,7 @@ Defined in: [packages/utils/src/arrayUtils.ts:117](https://github.com/lucasols/u
98
98
  function arrayWithPrevAndIndex<T>(array): object[];
99
99
  ```
100
100
 
101
- Defined in: [packages/utils/src/arrayUtils.ts:121](https://github.com/lucasols/utils/blob/main/packages/utils/src/arrayUtils.ts#L121)
101
+ Defined in: [packages/utils/src/arrayUtils.ts:142](https://github.com/lucasols/utils/blob/main/packages/utils/src/arrayUtils.ts#L142)
102
102
 
103
103
  #### Type Parameters
104
104
 
@@ -181,7 +181,7 @@ function findAfterIndex<T>(
181
181
  predicate): undefined | T;
182
182
  ```
183
183
 
184
- Defined in: [packages/utils/src/arrayUtils.ts:144](https://github.com/lucasols/utils/blob/main/packages/utils/src/arrayUtils.ts#L144)
184
+ Defined in: [packages/utils/src/arrayUtils.ts:165](https://github.com/lucasols/utils/blob/main/packages/utils/src/arrayUtils.ts#L165)
185
185
 
186
186
  #### Type Parameters
187
187
 
@@ -218,7 +218,7 @@ function findBeforeIndex<T>(
218
218
  predicate): undefined | T;
219
219
  ```
220
220
 
221
- Defined in: [packages/utils/src/arrayUtils.ts:158](https://github.com/lucasols/utils/blob/main/packages/utils/src/arrayUtils.ts#L158)
221
+ Defined in: [packages/utils/src/arrayUtils.ts:179](https://github.com/lucasols/utils/blob/main/packages/utils/src/arrayUtils.ts#L179)
222
222
 
223
223
  #### Type Parameters
224
224
 
@@ -246,13 +246,48 @@ Defined in: [packages/utils/src/arrayUtils.ts:158](https://github.com/lucasols/u
246
246
 
247
247
  ***
248
248
 
249
+ ### getAscIndexOrder()
250
+
251
+ ```ts
252
+ function getAscIndexOrder(index): number;
253
+ ```
254
+
255
+ Defined in: [packages/utils/src/arrayUtils.ts:134](https://github.com/lucasols/utils/blob/main/packages/utils/src/arrayUtils.ts#L134)
256
+
257
+ Get the correct 0 based value for sync with other array in ascending order
258
+
259
+ #### Parameters
260
+
261
+ ##### index
262
+
263
+ `undefined` | `number`
264
+
265
+ #### Returns
266
+
267
+ `number`
268
+
269
+ #### Example
270
+
271
+ ```ts
272
+ const items = [1, 2, 3];
273
+
274
+ const index = sortBy(
275
+ items,
276
+ (item) => getAscIndexOrder(
277
+ followOrder.findIndex((order) => order === item)
278
+ )
279
+ );
280
+ ```
281
+
282
+ ***
283
+
249
284
  ### hasDuplicates()
250
285
 
251
286
  ```ts
252
287
  function hasDuplicates<T>(array, getKey): boolean;
253
288
  ```
254
289
 
255
- Defined in: [packages/utils/src/arrayUtils.ts:182](https://github.com/lucasols/utils/blob/main/packages/utils/src/arrayUtils.ts#L182)
290
+ Defined in: [packages/utils/src/arrayUtils.ts:203](https://github.com/lucasols/utils/blob/main/packages/utils/src/arrayUtils.ts#L203)
256
291
 
257
292
  #### Type Parameters
258
293
 
@@ -282,7 +317,7 @@ Defined in: [packages/utils/src/arrayUtils.ts:182](https://github.com/lucasols/u
282
317
  function isInArray<T, U>(value, oneOf): value is U;
283
318
  ```
284
319
 
285
- Defined in: [packages/utils/src/arrayUtils.ts:131](https://github.com/lucasols/utils/blob/main/packages/utils/src/arrayUtils.ts#L131)
320
+ Defined in: [packages/utils/src/arrayUtils.ts:152](https://github.com/lucasols/utils/blob/main/packages/utils/src/arrayUtils.ts#L152)
286
321
 
287
322
  #### Type Parameters
288
323
 
@@ -316,7 +351,7 @@ readonly `U`[]
316
351
  function rejectArrayUndefinedValues<T>(array): T;
317
352
  ```
318
353
 
319
- Defined in: [packages/utils/src/arrayUtils.ts:178](https://github.com/lucasols/utils/blob/main/packages/utils/src/arrayUtils.ts#L178)
354
+ Defined in: [packages/utils/src/arrayUtils.ts:199](https://github.com/lucasols/utils/blob/main/packages/utils/src/arrayUtils.ts#L199)
320
355
 
321
356
  #### Type Parameters
322
357
 
@@ -342,7 +377,7 @@ Defined in: [packages/utils/src/arrayUtils.ts:178](https://github.com/lucasols/u
342
377
  function rejectDuplicates<T>(array, getKey): T[];
343
378
  ```
344
379
 
345
- Defined in: [packages/utils/src/arrayUtils.ts:199](https://github.com/lucasols/utils/blob/main/packages/utils/src/arrayUtils.ts#L199)
380
+ Defined in: [packages/utils/src/arrayUtils.ts:220](https://github.com/lucasols/utils/blob/main/packages/utils/src/arrayUtils.ts#L220)
346
381
 
347
382
  #### Type Parameters
348
383
 
@@ -432,7 +467,7 @@ function truncateArray<T>(
432
467
  appendIfTruncated?): T[];
433
468
  ```
434
469
 
435
- Defined in: [packages/utils/src/arrayUtils.ts:219](https://github.com/lucasols/utils/blob/main/packages/utils/src/arrayUtils.ts#L219)
470
+ Defined in: [packages/utils/src/arrayUtils.ts:240](https://github.com/lucasols/utils/blob/main/packages/utils/src/arrayUtils.ts#L240)
436
471
 
437
472
  #### Type Parameters
438
473
 
@@ -220,6 +220,26 @@ Defined in: [packages/utils/src/stringUtils.ts:50](https://github.com/lucasols/u
220
220
 
221
221
  ***
222
222
 
223
+ ### removeANSIColors()
224
+
225
+ ```ts
226
+ function removeANSIColors(str): string;
227
+ ```
228
+
229
+ Defined in: [packages/utils/src/stringUtils.ts:98](https://github.com/lucasols/utils/blob/main/packages/utils/src/stringUtils.ts#L98)
230
+
231
+ #### Parameters
232
+
233
+ ##### str
234
+
235
+ `string`
236
+
237
+ #### Returns
238
+
239
+ `string`
240
+
241
+ ***
242
+
223
243
  ### truncateString()
224
244
 
225
245
  ```ts
package/package.json CHANGED
@@ -1,10 +1,10 @@
1
1
  {
2
2
  "name": "@ls-stack/utils",
3
3
  "description": "Universal TypeScript utilities for browser and Node.js",
4
- "version": "3.33.0",
4
+ "version": "3.34.0",
5
5
  "license": "MIT",
6
6
  "files": [
7
- "lib",
7
+ "dist",
8
8
  "docs"
9
9
  ],
10
10
  "repository": "github:lucasols/utils",
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes