es-toolkit 1.9.0-dev.187 → 1.9.0-dev.188

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 (51) hide show
  1. package/dist/array/index.mjs +31 -31
  2. package/dist/chunk-55NY5XRN.mjs +14 -0
  3. package/dist/chunk-55NY5XRN.mjs.map +1 -0
  4. package/dist/chunk-R7WI75UB.mjs +14 -0
  5. package/dist/chunk-R7WI75UB.mjs.map +1 -0
  6. package/dist/chunk-SG4W5PWM.mjs +11 -0
  7. package/dist/chunk-SG4W5PWM.mjs.map +1 -0
  8. package/dist/chunk-TOORJ7XR.mjs +14 -0
  9. package/dist/chunk-TOORJ7XR.mjs.map +1 -0
  10. package/dist/function/index.mjs +6 -6
  11. package/dist/index.js +11 -14
  12. package/dist/index.js.map +1 -1
  13. package/dist/index.mjs +61 -62
  14. package/dist/math/index.mjs +9 -9
  15. package/dist/object/index.mjs +6 -6
  16. package/dist/predicate/index.mjs +6 -6
  17. package/dist/string/index.js +11 -14
  18. package/dist/string/index.js.map +1 -1
  19. package/dist/string/index.mjs +6 -7
  20. package/dist/string/kebabCase.js +7 -3
  21. package/dist/string/kebabCase.js.map +1 -1
  22. package/dist/string/kebabCase.mjs +2 -3
  23. package/dist/string/lowerCase.js +7 -10
  24. package/dist/string/lowerCase.js.map +1 -1
  25. package/dist/string/lowerCase.mjs +2 -3
  26. package/dist/string/snakeCase.js +7 -3
  27. package/dist/string/snakeCase.js.map +1 -1
  28. package/dist/string/snakeCase.mjs +2 -3
  29. package/package.json +1 -1
  30. package/dist/chunk-2AWSOSQI.mjs +0 -21
  31. package/dist/chunk-2AWSOSQI.mjs.map +0 -1
  32. package/dist/chunk-2M3YVRFS.mjs +0 -1
  33. package/dist/chunk-2M3YVRFS.mjs.map +0 -1
  34. package/dist/chunk-47QP3LTV.mjs +0 -14
  35. package/dist/chunk-47QP3LTV.mjs.map +0 -1
  36. package/dist/chunk-IJJCMZIV.mjs +0 -7
  37. package/dist/chunk-IJJCMZIV.mjs.map +0 -1
  38. package/dist/chunk-XWJ7NQF4.mjs +0 -14
  39. package/dist/chunk-XWJ7NQF4.mjs.map +0 -1
  40. package/dist/constants/caseSplitPattern.d.mts +0 -19
  41. package/dist/constants/caseSplitPattern.d.ts +0 -19
  42. package/dist/constants/caseSplitPattern.js +0 -31
  43. package/dist/constants/caseSplitPattern.js.map +0 -1
  44. package/dist/constants/caseSplitPattern.mjs +0 -8
  45. package/dist/constants/caseSplitPattern.mjs.map +0 -1
  46. package/dist/constants/index.d.mts +0 -1
  47. package/dist/constants/index.d.ts +0 -1
  48. package/dist/constants/index.js +0 -33
  49. package/dist/constants/index.js.map +0 -1
  50. package/dist/constants/index.mjs +0 -9
  51. package/dist/constants/index.mjs.map +0 -1
@@ -1,10 +1,4 @@
1
1
  import "../chunk-2MRZANXZ.mjs";
2
- import {
3
- xorBy
4
- } from "../chunk-Q47NGNXT.mjs";
5
- import {
6
- xorWith
7
- } from "../chunk-QRSJBBFY.mjs";
8
2
  import {
9
3
  zip
10
4
  } from "../chunk-IDCUZVJL.mjs";
@@ -14,15 +8,9 @@ import {
14
8
  import {
15
9
  zipWith
16
10
  } from "../chunk-4KYXHZ4R.mjs";
17
- import {
18
- unionWith
19
- } from "../chunk-2ZCITDMK.mjs";
20
11
  import {
21
12
  uniqBy
22
13
  } from "../chunk-OXAZEEGP.mjs";
23
- import {
24
- uniqWith
25
- } from "../chunk-237HGSZS.mjs";
26
14
  import {
27
15
  unzip
28
16
  } from "../chunk-UYZKMBDO.mjs";
@@ -36,11 +24,11 @@ import {
36
24
  xor
37
25
  } from "../chunk-L7FQX5MN.mjs";
38
26
  import {
39
- tail
40
- } from "../chunk-OF6NM4G7.mjs";
27
+ xorBy
28
+ } from "../chunk-Q47NGNXT.mjs";
41
29
  import {
42
- take
43
- } from "../chunk-ME352XO7.mjs";
30
+ xorWith
31
+ } from "../chunk-QRSJBBFY.mjs";
44
32
  import {
45
33
  takeRight
46
34
  } from "../chunk-IQLKIDXF.mjs";
@@ -56,18 +44,18 @@ import {
56
44
  import {
57
45
  union
58
46
  } from "../chunk-R6QA7PLZ.mjs";
59
- import {
60
- uniq
61
- } from "../chunk-DVK2N4KC.mjs";
62
47
  import {
63
48
  unionBy
64
49
  } from "../chunk-NFS7RWWE.mjs";
65
50
  import {
66
- last
67
- } from "../chunk-KPBQ7OUY.mjs";
51
+ unionWith
52
+ } from "../chunk-2ZCITDMK.mjs";
68
53
  import {
69
- maxBy
70
- } from "../chunk-OOKNBU4V.mjs";
54
+ uniqWith
55
+ } from "../chunk-237HGSZS.mjs";
56
+ import {
57
+ uniq
58
+ } from "../chunk-DVK2N4KC.mjs";
71
59
  import {
72
60
  minBy
73
61
  } from "../chunk-IJD7FE2Z.mjs";
@@ -89,11 +77,11 @@ import {
89
77
  shuffle
90
78
  } from "../chunk-G7UQ5PUR.mjs";
91
79
  import {
92
- groupBy
93
- } from "../chunk-E6E4RZLN.mjs";
80
+ tail
81
+ } from "../chunk-OF6NM4G7.mjs";
94
82
  import {
95
- head
96
- } from "../chunk-HM2JT2RX.mjs";
83
+ take
84
+ } from "../chunk-ME352XO7.mjs";
97
85
  import {
98
86
  initial
99
87
  } from "../chunk-XPSOKBRZ.mjs";
@@ -110,11 +98,11 @@ import {
110
98
  keyBy
111
99
  } from "../chunk-AJKZMN2V.mjs";
112
100
  import {
113
- drop
114
- } from "../chunk-S3CORED5.mjs";
101
+ last
102
+ } from "../chunk-KPBQ7OUY.mjs";
115
103
  import {
116
- dropRight
117
- } from "../chunk-JEKUA56R.mjs";
104
+ maxBy
105
+ } from "../chunk-OOKNBU4V.mjs";
118
106
  import {
119
107
  dropRightWhile
120
108
  } from "../chunk-JE6JKZU3.mjs";
@@ -133,6 +121,12 @@ import {
133
121
  import {
134
122
  forEachRight
135
123
  } from "../chunk-IEA53J7P.mjs";
124
+ import {
125
+ groupBy
126
+ } from "../chunk-E6E4RZLN.mjs";
127
+ import {
128
+ head
129
+ } from "../chunk-HM2JT2RX.mjs";
136
130
  import {
137
131
  chunk
138
132
  } from "../chunk-E6C5EZQA.mjs";
@@ -151,6 +145,12 @@ import {
151
145
  import {
152
146
  differenceWith
153
147
  } from "../chunk-6NVQAHXP.mjs";
148
+ import {
149
+ drop
150
+ } from "../chunk-S3CORED5.mjs";
151
+ import {
152
+ dropRight
153
+ } from "../chunk-JEKUA56R.mjs";
154
154
  import "../chunk-2MM5EJJX.mjs";
155
155
  export {
156
156
  chunk,
@@ -0,0 +1,14 @@
1
+ import {
2
+ getWords
3
+ } from "./chunk-SG4W5PWM.mjs";
4
+
5
+ // src/string/lowerCase.ts
6
+ var lowerCase = (str) => {
7
+ const words = getWords(str);
8
+ return words.map((word) => word.toLowerCase()).join(" ");
9
+ };
10
+
11
+ export {
12
+ lowerCase
13
+ };
14
+ //# sourceMappingURL=chunk-55NY5XRN.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/string/lowerCase.ts"],"sourcesContent":["import { getWords } from './_internal/getWords.ts';\n\n/**\n * Converts a string to lower case.\n *\n * Lower case is the naming convention in which each word is written in lowercase and separated by an space ( ) character.\n *\n * @param {string} str - The string that is to be changed to lower case.\n * @returns {string} - The converted string to lower case.\n *\n * @example\n * const convertedStr1 = lowerCase('camelCase') // returns 'camel case'\n * const convertedStr2 = lowerCase('some whitespace') // returns 'some whitespace'\n * const convertedStr3 = lowerCase('hyphen-text') // returns 'hyphen text'\n * const convertedStr4 = lowerCase('HTTPRequest') // returns 'http request'\n */\nexport const lowerCase = (str: string): string => {\n const words = getWords(str);\n return words.map(word => word.toLowerCase()).join(' ');\n};\n"],"mappings":";;;;;AAgBO,IAAM,YAAY,CAAC,QAAwB;AAChD,QAAM,QAAQ,SAAS,GAAG;AAC1B,SAAO,MAAM,IAAI,UAAQ,KAAK,YAAY,CAAC,EAAE,KAAK,GAAG;AACvD;","names":[]}
@@ -0,0 +1,14 @@
1
+ import {
2
+ getWords
3
+ } from "./chunk-SG4W5PWM.mjs";
4
+
5
+ // src/string/snakeCase.ts
6
+ var snakeCase = (str) => {
7
+ const words = getWords(str);
8
+ return words.map((word) => word.toLowerCase()).join("_");
9
+ };
10
+
11
+ export {
12
+ snakeCase
13
+ };
14
+ //# sourceMappingURL=chunk-R7WI75UB.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/string/snakeCase.ts"],"sourcesContent":["import { getWords } from './_internal/getWords.ts';\n\n/**\n * Converts a string to snake case.\n *\n * Snake case is the naming convention in which each word is written in lowercase and separated by an underscore (_) character.\n *\n * @param {string} str - The string that is to be changed to snake case.\n * @returns {string} - The converted string to snake case.\n *\n * @example\n * const convertedStr1 = snakeCase('camelCase') // returns 'camel_case'\n * const convertedStr2 = snakeCase('some whitespace') // returns 'some_whitespace'\n * const convertedStr3 = snakeCase('hyphen-text') // returns 'hyphen_text'\n * const convertedStr4 = snakeCase('HTTPRequest') // returns 'http_request'\n */\n\nexport const snakeCase = (str: string): string => {\n const words = getWords(str);\n return words.map(word => word.toLowerCase()).join('_');\n};\n"],"mappings":";;;;;AAiBO,IAAM,YAAY,CAAC,QAAwB;AAChD,QAAM,QAAQ,SAAS,GAAG;AAC1B,SAAO,MAAM,IAAI,UAAQ,KAAK,YAAY,CAAC,EAAE,KAAK,GAAG;AACvD;","names":[]}
@@ -0,0 +1,11 @@
1
+ // src/string/_internal/getWords.ts
2
+ var CASE_SPLIT_PATTERN = /[A-Z]{2,}(?=[A-Z][a-z]+[0-9]*|\b)|[A-Z]?[a-z]+[0-9]*|[A-Z]+|[0-9]+/g;
3
+ function getWords(str) {
4
+ var _a;
5
+ return Array.from((_a = str.match(CASE_SPLIT_PATTERN)) != null ? _a : []);
6
+ }
7
+
8
+ export {
9
+ getWords
10
+ };
11
+ //# sourceMappingURL=chunk-SG4W5PWM.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/string/_internal/getWords.ts"],"sourcesContent":["/**\n * Regular expression pattern to split strings into words for various case conversions\n *\n * This pattern matchs sequences of characters in a string, considering the following case:\n * - Sequences of two or more uppercase letters followed by an uppercase letter and lowercase letters or digits (for acronyms)\n * - Sequences of one uppercase letter optionally followed by lowercase letters and digits\n * - Single uppercase letters\n * - Sequences of digis\n *\n * The resulting match can be used to convert camelCase, snake_case, kebab-case, and other mixed formats into\n * a consistent format like snake case.\n *\n * @example\n * const matches = 'camelCaseHTTPRequest'.match(CASE_SPLIT_PATTERN);\n * // matchs: ['camel', 'Case', 'HTTP', 'Request']\n */\nconst CASE_SPLIT_PATTERN = /[A-Z]{2,}(?=[A-Z][a-z]+[0-9]*|\\b)|[A-Z]?[a-z]+[0-9]*|[A-Z]+|[0-9]+/g;\n\nexport function getWords(str: string): string[] {\n return Array.from(str.match(CASE_SPLIT_PATTERN) ?? []);\n}\n"],"mappings":";AAgBA,IAAM,qBAAqB;AAEpB,SAAS,SAAS,KAAuB;AAlBhD;AAmBE,SAAO,MAAM,MAAK,SAAI,MAAM,kBAAkB,MAA5B,YAAiC,CAAC,CAAC;AACvD;","names":[]}
@@ -0,0 +1,14 @@
1
+ import {
2
+ getWords
3
+ } from "./chunk-SG4W5PWM.mjs";
4
+
5
+ // src/string/kebabCase.ts
6
+ var kebabCase = (str) => {
7
+ const words = getWords(str);
8
+ return words.map((word) => word.toLowerCase()).join("-");
9
+ };
10
+
11
+ export {
12
+ kebabCase
13
+ };
14
+ //# sourceMappingURL=chunk-TOORJ7XR.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/string/kebabCase.ts"],"sourcesContent":["import { getWords } from './_internal/getWords.ts';\n\n/**\n * Converts a string to kebab case.\n *\n * Kebab case is the naming convention in which each word is written in lowercase and separated by a dash (-) character.\n *\n * @param {string} str - The string that is to be changed to kebab case.\n * @returns {string} - The converted string to kebab case.\n *\n * @example\n * const convertedStr1 = kebabCase('camelCase') // returns 'camel-case'\n * const convertedStr2 = kebabCase('some whitespace') // returns 'some-whitespace'\n * const convertedStr3 = kebabCase('hyphen-text') // returns 'hyphen-text'\n * const convertedStr4 = kebabCase('HTTPRequest') // returns 'http-request'\n */\n\nexport const kebabCase = (str: string): string => {\n const words = getWords(str);\n return words.map(word => word.toLowerCase()).join('-');\n};\n"],"mappings":";;;;;AAiBO,IAAM,YAAY,CAAC,QAAwB;AAChD,QAAM,QAAQ,SAAS,GAAG;AAC1B,SAAO,MAAM,IAAI,UAAQ,KAAK,YAAY,CAAC,EAAE,KAAK,GAAG;AACvD;","names":[]}
@@ -1,16 +1,16 @@
1
1
  import "../chunk-N6EM6ETS.mjs";
2
- import {
3
- once
4
- } from "../chunk-CMBC4MXG.mjs";
5
- import {
6
- throttle
7
- } from "../chunk-QOJGMVVR.mjs";
8
2
  import {
9
3
  debounce
10
4
  } from "../chunk-3IP4JVLL.mjs";
11
5
  import {
12
6
  noop
13
7
  } from "../chunk-LKXCOLNY.mjs";
8
+ import {
9
+ once
10
+ } from "../chunk-CMBC4MXG.mjs";
11
+ import {
12
+ throttle
13
+ } from "../chunk-QOJGMVVR.mjs";
14
14
  import "../chunk-2MM5EJJX.mjs";
15
15
  export {
16
16
  debounce,
package/dist/index.js CHANGED
@@ -854,32 +854,29 @@ function delay(ms, { signal } = {}) {
854
854
  });
855
855
  }
856
856
 
857
- // src/constants/caseSplitPattern.ts
857
+ // src/string/_internal/getWords.ts
858
858
  var CASE_SPLIT_PATTERN = /[A-Z]{2,}(?=[A-Z][a-z]+[0-9]*|\b)|[A-Z]?[a-z]+[0-9]*|[A-Z]+|[0-9]+/g;
859
+ function getWords(str) {
860
+ var _a;
861
+ return Array.from((_a = str.match(CASE_SPLIT_PATTERN)) != null ? _a : []);
862
+ }
859
863
 
860
864
  // src/string/snakeCase.ts
861
865
  var snakeCase = (str) => {
862
- const splitWords = str.match(CASE_SPLIT_PATTERN) || [];
863
- return splitWords.map((word) => word.toLowerCase()).join("_");
866
+ const words = getWords(str);
867
+ return words.map((word) => word.toLowerCase()).join("_");
864
868
  };
865
869
 
866
870
  // src/string/kebabCase.ts
867
871
  var kebabCase = (str) => {
868
- const splitWords = str.match(CASE_SPLIT_PATTERN) || [];
869
- return splitWords.map((word) => word.toLowerCase()).join("-");
872
+ const words = getWords(str);
873
+ return words.map((word) => word.toLowerCase()).join("-");
870
874
  };
871
875
 
872
876
  // src/string/lowerCase.ts
873
877
  var lowerCase = (str) => {
874
- const splitWords = str.match(CASE_SPLIT_PATTERN) || [];
875
- if (splitWords.length === 0) {
876
- return "";
877
- }
878
- let result = splitWords[0].toLowerCase();
879
- for (let i = 1; i < splitWords.length; i++) {
880
- result += " " + splitWords[i].toLowerCase();
881
- }
882
- return result;
878
+ const words = getWords(str);
879
+ return words.map((word) => word.toLowerCase()).join(" ");
883
880
  };
884
881
 
885
882
  // src/string/capitalize.ts