es-toolkit 1.9.0-dev.173 → 1.9.0-dev.174

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 (43) hide show
  1. package/dist/array/index.mjs +26 -26
  2. package/dist/chunk-2M3YVRFS.mjs +1 -0
  3. package/dist/chunk-2M3YVRFS.mjs.map +1 -0
  4. package/dist/chunk-T5URDZEQ.mjs +7 -0
  5. package/dist/chunk-T5URDZEQ.mjs.map +1 -0
  6. package/dist/chunk-VRFIBW4H.mjs +14 -0
  7. package/dist/chunk-VRFIBW4H.mjs.map +1 -0
  8. package/dist/chunk-YOFIBRET.mjs +1 -0
  9. package/dist/chunk-YOFIBRET.mjs.map +1 -0
  10. package/dist/constants/caseSplitPattern.d.mts +19 -0
  11. package/dist/constants/caseSplitPattern.d.ts +19 -0
  12. package/dist/constants/caseSplitPattern.js +31 -0
  13. package/dist/constants/caseSplitPattern.js.map +1 -0
  14. package/dist/constants/caseSplitPattern.mjs +8 -0
  15. package/dist/constants/caseSplitPattern.mjs.map +1 -0
  16. package/dist/constants/index.d.mts +1 -0
  17. package/dist/constants/index.d.ts +1 -0
  18. package/dist/constants/index.js +33 -0
  19. package/dist/constants/index.js.map +1 -0
  20. package/dist/constants/index.mjs +9 -0
  21. package/dist/constants/index.mjs.map +1 -0
  22. package/dist/function/index.mjs +6 -6
  23. package/dist/index.d.mts +1 -0
  24. package/dist/index.d.ts +1 -0
  25. package/dist/index.js +11 -0
  26. package/dist/index.js.map +1 -1
  27. package/dist/index.mjs +49 -42
  28. package/dist/math/index.mjs +3 -3
  29. package/dist/object/index.mjs +6 -6
  30. package/dist/string/index.d.mts +1 -0
  31. package/dist/string/index.d.ts +1 -0
  32. package/dist/string/index.js +39 -0
  33. package/dist/string/index.js.map +1 -0
  34. package/dist/string/index.mjs +11 -0
  35. package/dist/string/index.mjs.map +1 -0
  36. package/dist/string/snakeCase.d.mts +17 -0
  37. package/dist/string/snakeCase.d.ts +17 -0
  38. package/dist/string/snakeCase.js +39 -0
  39. package/dist/string/snakeCase.js.map +1 -0
  40. package/dist/string/snakeCase.mjs +10 -0
  41. package/dist/string/snakeCase.mjs.map +1 -0
  42. package/package.json +21 -1
  43. package/string.d.ts +1 -0
@@ -1,4 +1,13 @@
1
1
  import "../chunk-WGIVYA3P.mjs";
2
+ import {
3
+ zipObject
4
+ } from "../chunk-6GWEY5EL.mjs";
5
+ import {
6
+ zipWith
7
+ } from "../chunk-4KYXHZ4R.mjs";
8
+ import {
9
+ unzip
10
+ } from "../chunk-UYZKMBDO.mjs";
2
11
  import {
3
12
  unzipWith
4
13
  } from "../chunk-IFNXROZR.mjs";
@@ -18,11 +27,11 @@ import {
18
27
  zip
19
28
  } from "../chunk-IDCUZVJL.mjs";
20
29
  import {
21
- zipObject
22
- } from "../chunk-6GWEY5EL.mjs";
30
+ takeRight
31
+ } from "../chunk-IQLKIDXF.mjs";
23
32
  import {
24
- zipWith
25
- } from "../chunk-4KYXHZ4R.mjs";
33
+ takeRightWhile
34
+ } from "../chunk-NTLX2MPV.mjs";
26
35
  import {
27
36
  takeWhile
28
37
  } from "../chunk-2IXFGSUA.mjs";
@@ -35,6 +44,9 @@ import {
35
44
  import {
36
45
  unionWith
37
46
  } from "../chunk-2ZCITDMK.mjs";
47
+ import {
48
+ uniqWith
49
+ } from "../chunk-237HGSZS.mjs";
38
50
  import {
39
51
  uniq
40
52
  } from "../chunk-DVK2N4KC.mjs";
@@ -42,11 +54,11 @@ import {
42
54
  uniqBy
43
55
  } from "../chunk-OXAZEEGP.mjs";
44
56
  import {
45
- uniqWith
46
- } from "../chunk-237HGSZS.mjs";
57
+ minBy
58
+ } from "../chunk-IJD7FE2Z.mjs";
47
59
  import {
48
- unzip
49
- } from "../chunk-UYZKMBDO.mjs";
60
+ orderBy
61
+ } from "../chunk-7B7W36UP.mjs";
50
62
  import {
51
63
  partition
52
64
  } from "../chunk-DN3NOZ3H.mjs";
@@ -68,11 +80,8 @@ import {
68
80
  take
69
81
  } from "../chunk-ME352XO7.mjs";
70
82
  import {
71
- takeRight
72
- } from "../chunk-IQLKIDXF.mjs";
73
- import {
74
- takeRightWhile
75
- } from "../chunk-NTLX2MPV.mjs";
83
+ head
84
+ } from "../chunk-HM2JT2RX.mjs";
76
85
  import {
77
86
  intersection
78
87
  } from "../chunk-FVVSE2F2.mjs";
@@ -92,11 +101,11 @@ import {
92
101
  maxBy
93
102
  } from "../chunk-OOKNBU4V.mjs";
94
103
  import {
95
- minBy
96
- } from "../chunk-IJD7FE2Z.mjs";
104
+ drop
105
+ } from "../chunk-S3CORED5.mjs";
97
106
  import {
98
- orderBy
99
- } from "../chunk-7B7W36UP.mjs";
107
+ dropRight
108
+ } from "../chunk-JEKUA56R.mjs";
100
109
  import {
101
110
  dropRightWhile
102
111
  } from "../chunk-JE6JKZU3.mjs";
@@ -115,9 +124,6 @@ import {
115
124
  import {
116
125
  groupBy
117
126
  } from "../chunk-E6E4RZLN.mjs";
118
- import {
119
- head
120
- } from "../chunk-HM2JT2RX.mjs";
121
127
  import {
122
128
  chunk
123
129
  } from "../chunk-E6C5EZQA.mjs";
@@ -136,12 +142,6 @@ import {
136
142
  import {
137
143
  differenceWith
138
144
  } from "../chunk-6NVQAHXP.mjs";
139
- import {
140
- drop
141
- } from "../chunk-S3CORED5.mjs";
142
- import {
143
- dropRight
144
- } from "../chunk-JEKUA56R.mjs";
145
145
  import "../chunk-2MM5EJJX.mjs";
146
146
  export {
147
147
  chunk,
@@ -0,0 +1 @@
1
+ //# sourceMappingURL=chunk-2M3YVRFS.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
@@ -0,0 +1,7 @@
1
+ // src/constants/caseSplitPattern.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
+
4
+ export {
5
+ CASE_SPLIT_PATTERN
6
+ };
7
+ //# sourceMappingURL=chunk-T5URDZEQ.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/constants/caseSplitPattern.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 */\n\nexport const 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"],"mappings":";AAiBO,IAAM,qBAAqB;","names":[]}
@@ -0,0 +1,14 @@
1
+ import {
2
+ CASE_SPLIT_PATTERN
3
+ } from "./chunk-T5URDZEQ.mjs";
4
+
5
+ // src/string/snakeCase.ts
6
+ var snakeCase = (str) => {
7
+ const splitWords = str.match(CASE_SPLIT_PATTERN) || [];
8
+ return splitWords.map((word) => word.toLowerCase()).join("_");
9
+ };
10
+
11
+ export {
12
+ snakeCase
13
+ };
14
+ //# sourceMappingURL=chunk-VRFIBW4H.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/string/snakeCase.ts"],"sourcesContent":["import { CASE_SPLIT_PATTERN } from '../constants';\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 splitWords = str.match(CASE_SPLIT_PATTERN) || [];\n return splitWords.map(word => word.toLowerCase()).join('_');\n};\n"],"mappings":";;;;;AAiBO,IAAM,YAAY,CAAC,QAAwB;AAChD,QAAM,aAAa,IAAI,MAAM,kBAAkB,KAAK,CAAC;AACrD,SAAO,WAAW,IAAI,UAAQ,KAAK,YAAY,CAAC,EAAE,KAAK,GAAG;AAC5D;","names":[]}
@@ -0,0 +1 @@
1
+ //# sourceMappingURL=chunk-YOFIBRET.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
@@ -0,0 +1,19 @@
1
+ /**
2
+ * Regular expression pattern to split strings into words for various case conversions
3
+ *
4
+ * This pattern matchs sequences of characters in a string, considering the following case:
5
+ * - Sequences of two or more uppercase letters followed by an uppercase letter and lowercase letters or digits (for acronyms)
6
+ * - Sequences of one uppercase letter optionally followed by lowercase letters and digits
7
+ * - Single uppercase letters
8
+ * - Sequences of digis
9
+ *
10
+ * The resulting match can be used to convert camelCase, snake_case, kebab-case, and other mixed formats into
11
+ * a consistent format like snake case.
12
+ *
13
+ * @example
14
+ * const matches = 'camelCaseHTTPRequest'.match(CASE_SPLIT_PATTERN);
15
+ * // matchs: ['camel', 'Case', 'HTTP', 'Request']
16
+ */
17
+ declare const CASE_SPLIT_PATTERN: RegExp;
18
+
19
+ export { CASE_SPLIT_PATTERN };
@@ -0,0 +1,19 @@
1
+ /**
2
+ * Regular expression pattern to split strings into words for various case conversions
3
+ *
4
+ * This pattern matchs sequences of characters in a string, considering the following case:
5
+ * - Sequences of two or more uppercase letters followed by an uppercase letter and lowercase letters or digits (for acronyms)
6
+ * - Sequences of one uppercase letter optionally followed by lowercase letters and digits
7
+ * - Single uppercase letters
8
+ * - Sequences of digis
9
+ *
10
+ * The resulting match can be used to convert camelCase, snake_case, kebab-case, and other mixed formats into
11
+ * a consistent format like snake case.
12
+ *
13
+ * @example
14
+ * const matches = 'camelCaseHTTPRequest'.match(CASE_SPLIT_PATTERN);
15
+ * // matchs: ['camel', 'Case', 'HTTP', 'Request']
16
+ */
17
+ declare const CASE_SPLIT_PATTERN: RegExp;
18
+
19
+ export { CASE_SPLIT_PATTERN };
@@ -0,0 +1,31 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+
20
+ // src/constants/caseSplitPattern.ts
21
+ var caseSplitPattern_exports = {};
22
+ __export(caseSplitPattern_exports, {
23
+ CASE_SPLIT_PATTERN: () => CASE_SPLIT_PATTERN
24
+ });
25
+ module.exports = __toCommonJS(caseSplitPattern_exports);
26
+ 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;
27
+ // Annotate the CommonJS export names for ESM import in node:
28
+ 0 && (module.exports = {
29
+ CASE_SPLIT_PATTERN
30
+ });
31
+ //# sourceMappingURL=caseSplitPattern.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/constants/caseSplitPattern.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 */\n\nexport const 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"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAiBO,IAAM,qBAAqB;","names":[]}
@@ -0,0 +1,8 @@
1
+ import {
2
+ CASE_SPLIT_PATTERN
3
+ } from "../chunk-T5URDZEQ.mjs";
4
+ import "../chunk-2MM5EJJX.mjs";
5
+ export {
6
+ CASE_SPLIT_PATTERN
7
+ };
8
+ //# sourceMappingURL=caseSplitPattern.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
@@ -0,0 +1 @@
1
+ export { CASE_SPLIT_PATTERN } from './caseSplitPattern.mjs';
@@ -0,0 +1 @@
1
+ export { CASE_SPLIT_PATTERN } from './caseSplitPattern.js';
@@ -0,0 +1,33 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+
20
+ // src/constants/index.ts
21
+ var constants_exports = {};
22
+ __export(constants_exports, {
23
+ CASE_SPLIT_PATTERN: () => CASE_SPLIT_PATTERN
24
+ });
25
+ module.exports = __toCommonJS(constants_exports);
26
+
27
+ // src/constants/caseSplitPattern.ts
28
+ 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;
29
+ // Annotate the CommonJS export names for ESM import in node:
30
+ 0 && (module.exports = {
31
+ CASE_SPLIT_PATTERN
32
+ });
33
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/constants/index.ts","../../src/constants/caseSplitPattern.ts"],"sourcesContent":["export { CASE_SPLIT_PATTERN } from './caseSplitPattern';\n","/**\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 */\n\nexport const 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"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACiBO,IAAM,qBAAqB;","names":[]}
@@ -0,0 +1,9 @@
1
+ import "../chunk-2M3YVRFS.mjs";
2
+ import {
3
+ CASE_SPLIT_PATTERN
4
+ } from "../chunk-T5URDZEQ.mjs";
5
+ import "../chunk-2MM5EJJX.mjs";
6
+ export {
7
+ CASE_SPLIT_PATTERN
8
+ };
9
+ //# sourceMappingURL=index.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
@@ -1,16 +1,16 @@
1
1
  import "../chunk-N6EM6ETS.mjs";
2
- import {
3
- debounce
4
- } from "../chunk-3IP4JVLL.mjs";
5
- import {
6
- noop
7
- } from "../chunk-LKXCOLNY.mjs";
8
2
  import {
9
3
  once
10
4
  } from "../chunk-CMBC4MXG.mjs";
11
5
  import {
12
6
  throttle
13
7
  } from "../chunk-QOJGMVVR.mjs";
8
+ import {
9
+ debounce
10
+ } from "../chunk-3IP4JVLL.mjs";
11
+ import {
12
+ noop
13
+ } from "../chunk-LKXCOLNY.mjs";
14
14
  import "../chunk-2MM5EJJX.mjs";
15
15
  export {
16
16
  debounce,
package/dist/index.d.mts CHANGED
@@ -69,3 +69,4 @@ export { isNotNil } from './predicate/isNotNil.mjs';
69
69
  export { isNull } from './predicate/isNull.mjs';
70
70
  export { isUndefined } from './predicate/isUndefined.mjs';
71
71
  export { delay } from './promise/delay.mjs';
72
+ export { snakeCase } from './string/snakeCase.mjs';
package/dist/index.d.ts CHANGED
@@ -69,3 +69,4 @@ export { isNotNil } from './predicate/isNotNil.js';
69
69
  export { isNull } from './predicate/isNull.js';
70
70
  export { isUndefined } from './predicate/isUndefined.js';
71
71
  export { delay } from './promise/delay.js';
72
+ export { snakeCase } from './string/snakeCase.js';
package/dist/index.js CHANGED
@@ -83,6 +83,7 @@ __export(src_exports, {
83
83
  sample: () => sample,
84
84
  sampleSize: () => sampleSize,
85
85
  shuffle: () => shuffle,
86
+ snakeCase: () => snakeCase,
86
87
  sum: () => sum,
87
88
  tail: () => tail,
88
89
  take: () => take,
@@ -821,6 +822,15 @@ function delay(ms, { signal } = {}) {
821
822
  signal == null ? void 0 : signal.addEventListener("abort", abortHandler, { once: true });
822
823
  });
823
824
  }
825
+
826
+ // src/constants/caseSplitPattern.ts
827
+ 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;
828
+
829
+ // src/string/snakeCase.ts
830
+ var snakeCase = (str) => {
831
+ const splitWords = str.match(CASE_SPLIT_PATTERN) || [];
832
+ return splitWords.map((word) => word.toLowerCase()).join("_");
833
+ };
824
834
  // Annotate the CommonJS export names for ESM import in node:
825
835
  0 && (module.exports = {
826
836
  AbortError,
@@ -872,6 +882,7 @@ function delay(ms, { signal } = {}) {
872
882
  sample,
873
883
  sampleSize,
874
884
  shuffle,
885
+ snakeCase,
875
886
  sum,
876
887
  tail,
877
888
  take,