es-toolkit 1.9.0 → 1.10.0-dev.204

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 (253) hide show
  1. package/CHANGELOG.md +22 -1
  2. package/README.md +1 -1
  3. package/dist/array/chunk.mjs +1 -1
  4. package/dist/array/compact.mjs +1 -1
  5. package/dist/array/countBy.mjs +1 -1
  6. package/dist/array/difference.mjs +1 -1
  7. package/dist/array/differenceBy.mjs +1 -1
  8. package/dist/array/differenceWith.mjs +1 -1
  9. package/dist/array/drop.mjs +1 -1
  10. package/dist/array/dropRight.mjs +1 -1
  11. package/dist/array/dropRightWhile.mjs +1 -1
  12. package/dist/array/dropWhile.mjs +1 -1
  13. package/dist/array/fill.mjs +1 -1
  14. package/dist/array/flatten.mjs +1 -1
  15. package/dist/array/flattenDeep.d.mts +25 -0
  16. package/dist/array/flattenDeep.d.ts +25 -0
  17. package/dist/array/flattenDeep.js +52 -0
  18. package/dist/array/flattenDeep.js.map +1 -0
  19. package/dist/array/flattenDeep.mjs +9 -0
  20. package/dist/array/forEachRight.mjs +1 -1
  21. package/dist/array/groupBy.mjs +1 -1
  22. package/dist/array/head.mjs +1 -1
  23. package/dist/array/index.d.mts +4 -0
  24. package/dist/array/index.d.ts +4 -0
  25. package/dist/array/index.js +38 -0
  26. package/dist/array/index.js.map +1 -1
  27. package/dist/array/index.mjs +45 -29
  28. package/dist/array/initial.d.mts +26 -0
  29. package/dist/array/initial.d.ts +26 -0
  30. package/dist/array/initial.js +36 -0
  31. package/dist/array/initial.js.map +1 -0
  32. package/dist/array/initial.mjs +8 -0
  33. package/dist/array/intersection.mjs +1 -1
  34. package/dist/array/intersectionBy.mjs +1 -1
  35. package/dist/array/intersectionWith.mjs +1 -1
  36. package/dist/array/keyBy.mjs +1 -1
  37. package/dist/array/last.d.mts +25 -0
  38. package/dist/array/last.d.ts +25 -0
  39. package/dist/array/last.js +33 -0
  40. package/dist/array/last.js.map +1 -0
  41. package/dist/array/last.mjs +8 -0
  42. package/dist/array/maxBy.mjs +1 -1
  43. package/dist/array/minBy.mjs +1 -1
  44. package/dist/array/orderBy.mjs +1 -1
  45. package/dist/array/partition.mjs +1 -1
  46. package/dist/array/sample.mjs +1 -1
  47. package/dist/array/sampleSize.mjs +1 -1
  48. package/dist/array/shuffle.mjs +1 -1
  49. package/dist/array/tail.mjs +1 -1
  50. package/dist/array/take.mjs +1 -1
  51. package/dist/array/takeRight.mjs +1 -1
  52. package/dist/array/takeRightWhile.mjs +1 -1
  53. package/dist/array/takeWhile.mjs +1 -1
  54. package/dist/array/toFilled.d.mts +33 -0
  55. package/dist/array/toFilled.d.ts +33 -0
  56. package/dist/array/toFilled.js +40 -0
  57. package/dist/array/toFilled.js.map +1 -0
  58. package/dist/array/toFilled.mjs +8 -0
  59. package/dist/array/union.mjs +1 -1
  60. package/dist/array/unionBy.mjs +1 -1
  61. package/dist/array/unionWith.mjs +1 -1
  62. package/dist/array/uniq.mjs +1 -1
  63. package/dist/array/uniqBy.mjs +1 -1
  64. package/dist/array/uniqWith.mjs +1 -1
  65. package/dist/array/unzip.mjs +1 -1
  66. package/dist/array/unzipWith.mjs +1 -1
  67. package/dist/array/without.mjs +1 -1
  68. package/dist/array/xor.mjs +1 -1
  69. package/dist/array/xorBy.mjs +1 -1
  70. package/dist/array/xorWith.mjs +1 -1
  71. package/dist/array/zip.mjs +1 -1
  72. package/dist/array/zipObject.mjs +1 -1
  73. package/dist/array/zipWith.mjs +1 -1
  74. package/dist/chunk-236H5JZJ.mjs +1 -0
  75. package/dist/chunk-2HIMLZE3.mjs +46 -0
  76. package/dist/chunk-2HIMLZE3.mjs.map +1 -0
  77. package/dist/chunk-2MRZANXZ.mjs +1 -0
  78. package/dist/chunk-2MRZANXZ.mjs.map +1 -0
  79. package/dist/chunk-2SLTL4KL.mjs +13 -0
  80. package/dist/{chunk-NOFHNJ5C.mjs.map → chunk-2SLTL4KL.mjs.map} +1 -1
  81. package/dist/{chunk-QZITBKWX.mjs → chunk-4E4D3BMI.mjs} +2 -2
  82. package/dist/chunk-5IKVJGHO.mjs +14 -0
  83. package/dist/chunk-5IKVJGHO.mjs.map +1 -0
  84. package/dist/chunk-ASJF5D6C.mjs +1 -0
  85. package/dist/chunk-ASJF5D6C.mjs.map +1 -0
  86. package/dist/chunk-BOOQBJN2.mjs +9 -0
  87. package/dist/chunk-BOOQBJN2.mjs.map +1 -0
  88. package/dist/chunk-EYYZQFOP.mjs +14 -0
  89. package/dist/chunk-EYYZQFOP.mjs.map +1 -0
  90. package/dist/chunk-F3WCQQET.mjs +14 -0
  91. package/dist/chunk-F3WCQQET.mjs.map +1 -0
  92. package/dist/{chunk-LT6E4Y4Z.mjs → chunk-GDC64SYJ.mjs} +2 -2
  93. package/dist/{chunk-SDIMTYZW.mjs → chunk-IZAD2S7R.mjs} +2 -2
  94. package/dist/chunk-JYSV56US.mjs +41 -0
  95. package/dist/chunk-JYSV56US.mjs.map +1 -0
  96. package/dist/chunk-KPBQ7OUY.mjs +9 -0
  97. package/dist/chunk-KPBQ7OUY.mjs.map +1 -0
  98. package/dist/chunk-ML727RRJ.mjs +13 -0
  99. package/dist/chunk-ML727RRJ.mjs.map +1 -0
  100. package/dist/chunk-NKLIE2OI.mjs +1 -0
  101. package/dist/chunk-NKLIE2OI.mjs.map +1 -0
  102. package/dist/chunk-OP4OAKQJ.mjs +16 -0
  103. package/dist/chunk-OP4OAKQJ.mjs.map +1 -0
  104. package/dist/chunk-OSOLEQLZ.mjs +1 -0
  105. package/dist/chunk-OSOLEQLZ.mjs.map +1 -0
  106. package/dist/chunk-QKYYOLJ6.mjs +1 -0
  107. package/dist/chunk-QKYYOLJ6.mjs.map +1 -0
  108. package/dist/chunk-U4JGKZ56.mjs +41 -0
  109. package/dist/chunk-U4JGKZ56.mjs.map +1 -0
  110. package/dist/chunk-U56ZOM7L.mjs +9 -0
  111. package/dist/chunk-U56ZOM7L.mjs.map +1 -0
  112. package/dist/chunk-WMM7TZLG.mjs +9 -0
  113. package/dist/{chunk-OHQAR5AU.mjs.map → chunk-WMM7TZLG.mjs.map} +1 -1
  114. package/dist/chunk-WVQ7YVRK.mjs +11 -0
  115. package/dist/chunk-WVQ7YVRK.mjs.map +1 -0
  116. package/dist/chunk-XGCYC4YA.mjs +5516 -0
  117. package/dist/chunk-XGCYC4YA.mjs.map +1 -0
  118. package/dist/chunk-XPSOKBRZ.mjs +12 -0
  119. package/dist/chunk-XPSOKBRZ.mjs.map +1 -0
  120. package/dist/compat/index.d.mts +108 -0
  121. package/dist/compat/index.d.ts +108 -0
  122. package/dist/compat/index.js +6578 -0
  123. package/dist/compat/index.js.map +1 -0
  124. package/dist/compat/index.mjs +351 -0
  125. package/dist/compat/index.mjs.map +1 -0
  126. package/dist/error/AbortError.mjs +1 -1
  127. package/dist/error/index.mjs +1 -1
  128. package/dist/function/debounce.mjs +1 -1
  129. package/dist/function/index.d.mts +1 -0
  130. package/dist/function/index.d.ts +1 -0
  131. package/dist/function/index.js +7 -0
  132. package/dist/function/index.js.map +1 -1
  133. package/dist/function/index.mjs +8 -4
  134. package/dist/function/negate.d.mts +10 -0
  135. package/dist/function/negate.d.ts +10 -0
  136. package/dist/function/negate.js +33 -0
  137. package/dist/function/negate.js.map +1 -0
  138. package/dist/function/negate.mjs +8 -0
  139. package/dist/function/negate.mjs.map +1 -0
  140. package/dist/function/noop.mjs +1 -1
  141. package/dist/function/once.mjs +1 -1
  142. package/dist/function/throttle.mjs +1 -1
  143. package/dist/index.d.mts +12 -0
  144. package/dist/index.d.ts +12 -0
  145. package/dist/index.js +5681 -3
  146. package/dist/index.js.map +1 -1
  147. package/dist/index.mjs +101 -50
  148. package/dist/math/clamp.mjs +1 -1
  149. package/dist/math/inRange.mjs +1 -1
  150. package/dist/math/index.js +2 -2
  151. package/dist/math/index.js.map +1 -1
  152. package/dist/math/index.mjs +9 -9
  153. package/dist/math/mean.js +2 -2
  154. package/dist/math/mean.js.map +1 -1
  155. package/dist/math/mean.mjs +3 -3
  156. package/dist/math/meanBy.js +2 -2
  157. package/dist/math/meanBy.js.map +1 -1
  158. package/dist/math/meanBy.mjs +4 -4
  159. package/dist/math/random.mjs +1 -1
  160. package/dist/math/randomInt.mjs +1 -1
  161. package/dist/math/range.mjs +1 -1
  162. package/dist/math/round.mjs +1 -1
  163. package/dist/math/sum.js +2 -2
  164. package/dist/math/sum.js.map +1 -1
  165. package/dist/math/sum.mjs +2 -2
  166. package/dist/object/clone.d.mts +31 -0
  167. package/dist/object/clone.d.ts +31 -0
  168. package/dist/object/clone.js +65 -0
  169. package/dist/object/clone.js.map +1 -0
  170. package/dist/object/clone.mjs +8 -0
  171. package/dist/object/clone.mjs.map +1 -0
  172. package/dist/object/index.d.mts +1 -0
  173. package/dist/object/index.d.ts +1 -0
  174. package/dist/object/index.js +39 -0
  175. package/dist/object/index.js.map +1 -1
  176. package/dist/object/index.mjs +7 -3
  177. package/dist/object/invert.mjs +1 -1
  178. package/dist/object/omit.mjs +2 -2
  179. package/dist/object/omitBy.mjs +1 -1
  180. package/dist/object/pick.mjs +1 -1
  181. package/dist/object/pickBy.mjs +1 -1
  182. package/dist/predicate/index.d.mts +1 -0
  183. package/dist/predicate/index.d.ts +1 -0
  184. package/dist/predicate/index.js +46 -1
  185. package/dist/predicate/index.js.map +1 -1
  186. package/dist/predicate/index.mjs +9 -3
  187. package/dist/predicate/isEqual.d.mts +17 -0
  188. package/dist/predicate/isEqual.d.ts +17 -0
  189. package/dist/predicate/isEqual.js +73 -0
  190. package/dist/predicate/isEqual.js.map +1 -0
  191. package/dist/predicate/isEqual.mjs +10 -0
  192. package/dist/predicate/isEqual.mjs.map +1 -0
  193. package/dist/predicate/isNil.js +1 -1
  194. package/dist/predicate/isNil.js.map +1 -1
  195. package/dist/predicate/isNil.mjs +2 -2
  196. package/dist/predicate/isNotNil.mjs +1 -1
  197. package/dist/predicate/isNull.mjs +1 -1
  198. package/dist/predicate/isUndefined.mjs +1 -1
  199. package/dist/promise/delay.mjs +1 -1
  200. package/dist/promise/index.mjs +1 -1
  201. package/dist/string/camelCase.d.mts +17 -0
  202. package/dist/string/camelCase.d.ts +17 -0
  203. package/dist/string/camelCase.js +5554 -0
  204. package/dist/string/camelCase.js.map +1 -0
  205. package/dist/string/camelCase.mjs +9 -0
  206. package/dist/string/camelCase.mjs.map +1 -0
  207. package/dist/string/capitalize.d.mts +14 -0
  208. package/dist/string/capitalize.d.ts +14 -0
  209. package/dist/string/capitalize.js +33 -0
  210. package/dist/string/capitalize.js.map +1 -0
  211. package/dist/string/capitalize.mjs +8 -0
  212. package/dist/string/capitalize.mjs.map +1 -0
  213. package/dist/string/index.d.mts +5 -0
  214. package/dist/string/index.d.ts +5 -0
  215. package/dist/string/index.js +5587 -0
  216. package/dist/string/index.js.map +1 -0
  217. package/dist/string/index.mjs +26 -0
  218. package/dist/string/index.mjs.map +1 -0
  219. package/dist/string/kebabCase.d.mts +17 -0
  220. package/dist/string/kebabCase.d.ts +17 -0
  221. package/dist/string/kebabCase.js +43 -0
  222. package/dist/string/kebabCase.js.map +1 -0
  223. package/dist/string/kebabCase.mjs +9 -0
  224. package/dist/string/kebabCase.mjs.map +1 -0
  225. package/dist/string/lowerCase.d.mts +17 -0
  226. package/dist/string/lowerCase.d.ts +17 -0
  227. package/dist/string/lowerCase.js +43 -0
  228. package/dist/string/lowerCase.js.map +1 -0
  229. package/dist/string/lowerCase.mjs +9 -0
  230. package/dist/string/lowerCase.mjs.map +1 -0
  231. package/dist/string/snakeCase.d.mts +17 -0
  232. package/dist/string/snakeCase.d.ts +17 -0
  233. package/dist/string/snakeCase.js +43 -0
  234. package/dist/string/snakeCase.js.map +1 -0
  235. package/dist/string/snakeCase.mjs +9 -0
  236. package/dist/string/snakeCase.mjs.map +1 -0
  237. package/package.json +21 -1
  238. package/string.d.ts +1 -0
  239. package/dist/chunk-2MM5EJJX.mjs +0 -21
  240. package/dist/chunk-LOY6PATI.mjs +0 -1
  241. package/dist/chunk-MAJSPFA6.mjs +0 -1
  242. package/dist/chunk-N6EM6ETS.mjs +0 -1
  243. package/dist/chunk-NOFHNJ5C.mjs +0 -13
  244. package/dist/chunk-OHQAR5AU.mjs +0 -9
  245. package/dist/chunk-PMHULJNL.mjs +0 -1
  246. /package/dist/{chunk-2MM5EJJX.mjs.map → array/flattenDeep.mjs.map} +0 -0
  247. /package/dist/{chunk-LOY6PATI.mjs.map → array/initial.mjs.map} +0 -0
  248. /package/dist/{chunk-MAJSPFA6.mjs.map → array/last.mjs.map} +0 -0
  249. /package/dist/{chunk-N6EM6ETS.mjs.map → array/toFilled.mjs.map} +0 -0
  250. /package/dist/{chunk-PMHULJNL.mjs.map → chunk-236H5JZJ.mjs.map} +0 -0
  251. /package/dist/{chunk-QZITBKWX.mjs.map → chunk-4E4D3BMI.mjs.map} +0 -0
  252. /package/dist/{chunk-LT6E4Y4Z.mjs.map → chunk-GDC64SYJ.mjs.map} +0 -0
  253. /package/dist/{chunk-SDIMTYZW.mjs.map → chunk-IZAD2S7R.mjs.map} +0 -0
@@ -0,0 +1,26 @@
1
+ import "../chunk-QKYYOLJ6.mjs";
2
+ import {
3
+ kebabCase
4
+ } from "../chunk-EYYZQFOP.mjs";
5
+ import {
6
+ lowerCase
7
+ } from "../chunk-5IKVJGHO.mjs";
8
+ import {
9
+ snakeCase
10
+ } from "../chunk-F3WCQQET.mjs";
11
+ import {
12
+ camelCase
13
+ } from "../chunk-XGCYC4YA.mjs";
14
+ import "../chunk-WVQ7YVRK.mjs";
15
+ import {
16
+ capitalize
17
+ } from "../chunk-U56ZOM7L.mjs";
18
+ import "../chunk-2HIMLZE3.mjs";
19
+ export {
20
+ camelCase,
21
+ capitalize,
22
+ kebabCase,
23
+ lowerCase,
24
+ snakeCase
25
+ };
26
+ //# sourceMappingURL=index.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
@@ -0,0 +1,17 @@
1
+ /**
2
+ * Converts a string to kebab case.
3
+ *
4
+ * Kebab case is the naming convention in which each word is written in lowercase and separated by a dash (-) character.
5
+ *
6
+ * @param {string} str - The string that is to be changed to kebab case.
7
+ * @returns {string} - The converted string to kebab case.
8
+ *
9
+ * @example
10
+ * const convertedStr1 = kebabCase('camelCase') // returns 'camel-case'
11
+ * const convertedStr2 = kebabCase('some whitespace') // returns 'some-whitespace'
12
+ * const convertedStr3 = kebabCase('hyphen-text') // returns 'hyphen-text'
13
+ * const convertedStr4 = kebabCase('HTTPRequest') // returns 'http-request'
14
+ */
15
+ declare const kebabCase: (str: string) => string;
16
+
17
+ export { kebabCase };
@@ -0,0 +1,17 @@
1
+ /**
2
+ * Converts a string to kebab case.
3
+ *
4
+ * Kebab case is the naming convention in which each word is written in lowercase and separated by a dash (-) character.
5
+ *
6
+ * @param {string} str - The string that is to be changed to kebab case.
7
+ * @returns {string} - The converted string to kebab case.
8
+ *
9
+ * @example
10
+ * const convertedStr1 = kebabCase('camelCase') // returns 'camel-case'
11
+ * const convertedStr2 = kebabCase('some whitespace') // returns 'some-whitespace'
12
+ * const convertedStr3 = kebabCase('hyphen-text') // returns 'hyphen-text'
13
+ * const convertedStr4 = kebabCase('HTTPRequest') // returns 'http-request'
14
+ */
15
+ declare const kebabCase: (str: string) => string;
16
+
17
+ export { kebabCase };
@@ -0,0 +1,43 @@
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/string/kebabCase.ts
21
+ var kebabCase_exports = {};
22
+ __export(kebabCase_exports, {
23
+ kebabCase: () => kebabCase
24
+ });
25
+ module.exports = __toCommonJS(kebabCase_exports);
26
+
27
+ // src/string/_internal/getWords.ts
28
+ var CASE_SPLIT_PATTERN = /[A-Z]?[a-z]+|[0-9]+|[A-Z]+(?![a-z])/g;
29
+ function getWords(str) {
30
+ var _a;
31
+ return Array.from((_a = str.match(CASE_SPLIT_PATTERN)) != null ? _a : []);
32
+ }
33
+
34
+ // src/string/kebabCase.ts
35
+ var kebabCase = (str) => {
36
+ const words = getWords(str);
37
+ return words.map((word) => word.toLowerCase()).join("-");
38
+ };
39
+ // Annotate the CommonJS export names for ESM import in node:
40
+ 0 && (module.exports = {
41
+ kebabCase
42
+ });
43
+ //# sourceMappingURL=kebabCase.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/string/kebabCase.ts","../../src/string/_internal/getWords.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","/**\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]?[a-z]+|[0-9]+|[A-Z]+(?![a-z])/g;\n\nexport function getWords(str: string): string[] {\n return Array.from(str.match(CASE_SPLIT_PATTERN) ?? []);\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACgBA,IAAM,qBAAqB;AAEpB,SAAS,SAAS,KAAuB;AAlBhD;AAmBE,SAAO,MAAM,MAAK,SAAI,MAAM,kBAAkB,MAA5B,YAAiC,CAAC,CAAC;AACvD;;;ADHO,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,9 @@
1
+ import {
2
+ kebabCase
3
+ } from "../chunk-EYYZQFOP.mjs";
4
+ import "../chunk-WVQ7YVRK.mjs";
5
+ import "../chunk-2HIMLZE3.mjs";
6
+ export {
7
+ kebabCase
8
+ };
9
+ //# sourceMappingURL=kebabCase.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
@@ -0,0 +1,17 @@
1
+ /**
2
+ * Converts a string to lower case.
3
+ *
4
+ * Lower case is the naming convention in which each word is written in lowercase and separated by an space ( ) character.
5
+ *
6
+ * @param {string} str - The string that is to be changed to lower case.
7
+ * @returns {string} - The converted string to lower case.
8
+ *
9
+ * @example
10
+ * const convertedStr1 = lowerCase('camelCase') // returns 'camel case'
11
+ * const convertedStr2 = lowerCase('some whitespace') // returns 'some whitespace'
12
+ * const convertedStr3 = lowerCase('hyphen-text') // returns 'hyphen text'
13
+ * const convertedStr4 = lowerCase('HTTPRequest') // returns 'http request'
14
+ */
15
+ declare const lowerCase: (str: string) => string;
16
+
17
+ export { lowerCase };
@@ -0,0 +1,17 @@
1
+ /**
2
+ * Converts a string to lower case.
3
+ *
4
+ * Lower case is the naming convention in which each word is written in lowercase and separated by an space ( ) character.
5
+ *
6
+ * @param {string} str - The string that is to be changed to lower case.
7
+ * @returns {string} - The converted string to lower case.
8
+ *
9
+ * @example
10
+ * const convertedStr1 = lowerCase('camelCase') // returns 'camel case'
11
+ * const convertedStr2 = lowerCase('some whitespace') // returns 'some whitespace'
12
+ * const convertedStr3 = lowerCase('hyphen-text') // returns 'hyphen text'
13
+ * const convertedStr4 = lowerCase('HTTPRequest') // returns 'http request'
14
+ */
15
+ declare const lowerCase: (str: string) => string;
16
+
17
+ export { lowerCase };
@@ -0,0 +1,43 @@
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/string/lowerCase.ts
21
+ var lowerCase_exports = {};
22
+ __export(lowerCase_exports, {
23
+ lowerCase: () => lowerCase
24
+ });
25
+ module.exports = __toCommonJS(lowerCase_exports);
26
+
27
+ // src/string/_internal/getWords.ts
28
+ var CASE_SPLIT_PATTERN = /[A-Z]?[a-z]+|[0-9]+|[A-Z]+(?![a-z])/g;
29
+ function getWords(str) {
30
+ var _a;
31
+ return Array.from((_a = str.match(CASE_SPLIT_PATTERN)) != null ? _a : []);
32
+ }
33
+
34
+ // src/string/lowerCase.ts
35
+ var lowerCase = (str) => {
36
+ const words = getWords(str);
37
+ return words.map((word) => word.toLowerCase()).join(" ");
38
+ };
39
+ // Annotate the CommonJS export names for ESM import in node:
40
+ 0 && (module.exports = {
41
+ lowerCase
42
+ });
43
+ //# sourceMappingURL=lowerCase.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/string/lowerCase.ts","../../src/string/_internal/getWords.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","/**\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]?[a-z]+|[0-9]+|[A-Z]+(?![a-z])/g;\n\nexport function getWords(str: string): string[] {\n return Array.from(str.match(CASE_SPLIT_PATTERN) ?? []);\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACgBA,IAAM,qBAAqB;AAEpB,SAAS,SAAS,KAAuB;AAlBhD;AAmBE,SAAO,MAAM,MAAK,SAAI,MAAM,kBAAkB,MAA5B,YAAiC,CAAC,CAAC;AACvD;;;ADJO,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,9 @@
1
+ import {
2
+ lowerCase
3
+ } from "../chunk-5IKVJGHO.mjs";
4
+ import "../chunk-WVQ7YVRK.mjs";
5
+ import "../chunk-2HIMLZE3.mjs";
6
+ export {
7
+ lowerCase
8
+ };
9
+ //# sourceMappingURL=lowerCase.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
@@ -0,0 +1,17 @@
1
+ /**
2
+ * Converts a string to snake case.
3
+ *
4
+ * Snake case is the naming convention in which each word is written in lowercase and separated by an underscore (_) character.
5
+ *
6
+ * @param {string} str - The string that is to be changed to snake case.
7
+ * @returns {string} - The converted string to snake case.
8
+ *
9
+ * @example
10
+ * const convertedStr1 = snakeCase('camelCase') // returns 'camel_case'
11
+ * const convertedStr2 = snakeCase('some whitespace') // returns 'some_whitespace'
12
+ * const convertedStr3 = snakeCase('hyphen-text') // returns 'hyphen_text'
13
+ * const convertedStr4 = snakeCase('HTTPRequest') // returns 'http_request'
14
+ */
15
+ declare const snakeCase: (str: string) => string;
16
+
17
+ export { snakeCase };
@@ -0,0 +1,17 @@
1
+ /**
2
+ * Converts a string to snake case.
3
+ *
4
+ * Snake case is the naming convention in which each word is written in lowercase and separated by an underscore (_) character.
5
+ *
6
+ * @param {string} str - The string that is to be changed to snake case.
7
+ * @returns {string} - The converted string to snake case.
8
+ *
9
+ * @example
10
+ * const convertedStr1 = snakeCase('camelCase') // returns 'camel_case'
11
+ * const convertedStr2 = snakeCase('some whitespace') // returns 'some_whitespace'
12
+ * const convertedStr3 = snakeCase('hyphen-text') // returns 'hyphen_text'
13
+ * const convertedStr4 = snakeCase('HTTPRequest') // returns 'http_request'
14
+ */
15
+ declare const snakeCase: (str: string) => string;
16
+
17
+ export { snakeCase };
@@ -0,0 +1,43 @@
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/string/snakeCase.ts
21
+ var snakeCase_exports = {};
22
+ __export(snakeCase_exports, {
23
+ snakeCase: () => snakeCase
24
+ });
25
+ module.exports = __toCommonJS(snakeCase_exports);
26
+
27
+ // src/string/_internal/getWords.ts
28
+ var CASE_SPLIT_PATTERN = /[A-Z]?[a-z]+|[0-9]+|[A-Z]+(?![a-z])/g;
29
+ function getWords(str) {
30
+ var _a;
31
+ return Array.from((_a = str.match(CASE_SPLIT_PATTERN)) != null ? _a : []);
32
+ }
33
+
34
+ // src/string/snakeCase.ts
35
+ var snakeCase = (str) => {
36
+ const words = getWords(str);
37
+ return words.map((word) => word.toLowerCase()).join("_");
38
+ };
39
+ // Annotate the CommonJS export names for ESM import in node:
40
+ 0 && (module.exports = {
41
+ snakeCase
42
+ });
43
+ //# sourceMappingURL=snakeCase.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/string/snakeCase.ts","../../src/string/_internal/getWords.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","/**\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]?[a-z]+|[0-9]+|[A-Z]+(?![a-z])/g;\n\nexport function getWords(str: string): string[] {\n return Array.from(str.match(CASE_SPLIT_PATTERN) ?? []);\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACgBA,IAAM,qBAAqB;AAEpB,SAAS,SAAS,KAAuB;AAlBhD;AAmBE,SAAO,MAAM,MAAK,SAAI,MAAM,kBAAkB,MAA5B,YAAiC,CAAC,CAAC;AACvD;;;ADHO,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,9 @@
1
+ import {
2
+ snakeCase
3
+ } from "../chunk-F3WCQQET.mjs";
4
+ import "../chunk-WVQ7YVRK.mjs";
5
+ import "../chunk-2HIMLZE3.mjs";
6
+ export {
7
+ snakeCase
8
+ };
9
+ //# sourceMappingURL=snakeCase.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "es-toolkit",
3
3
  "description": "A state-of-the-art, high-performance JavaScript utility library with a small bundle size and strong type annotations.",
4
- "version": "1.9.0",
4
+ "version": "1.10.0-dev.204+acb74650",
5
5
  "homepage": "https://es-toolkit.slash.page",
6
6
  "bugs": "https://github.com/toss/es-toolkit/issues",
7
7
  "repository": {
@@ -84,6 +84,16 @@
84
84
  "default": "./dist/promise/index.js"
85
85
  }
86
86
  },
87
+ "./string": {
88
+ "import": {
89
+ "types": "./dist/string/index.d.mts",
90
+ "default": "./dist/string/index.mjs"
91
+ },
92
+ "require": {
93
+ "types": "./dist/string/index.d.ts",
94
+ "default": "./dist/string/index.js"
95
+ }
96
+ },
87
97
  "./package.json": "./package.json"
88
98
  },
89
99
  "files": [
@@ -166,6 +176,16 @@
166
176
  "default": "./dist/promise/index.js"
167
177
  }
168
178
  },
179
+ "./string": {
180
+ "import": {
181
+ "types": "./dist/string/index.d.mts",
182
+ "default": "./dist/string/index.mjs"
183
+ },
184
+ "require": {
185
+ "types": "./dist/string/index.d.ts",
186
+ "default": "./dist/string/index.js"
187
+ }
188
+ },
169
189
  "./package.json": "./package.json"
170
190
  }
171
191
  },
package/string.d.ts ADDED
@@ -0,0 +1 @@
1
+ export * from './dist/string';
@@ -1,21 +0,0 @@
1
- var __defProp = Object.defineProperty;
2
- var __getOwnPropSymbols = Object.getOwnPropertySymbols;
3
- var __hasOwnProp = Object.prototype.hasOwnProperty;
4
- var __propIsEnum = Object.prototype.propertyIsEnumerable;
5
- var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
6
- var __spreadValues = (a, b) => {
7
- for (var prop in b || (b = {}))
8
- if (__hasOwnProp.call(b, prop))
9
- __defNormalProp(a, prop, b[prop]);
10
- if (__getOwnPropSymbols)
11
- for (var prop of __getOwnPropSymbols(b)) {
12
- if (__propIsEnum.call(b, prop))
13
- __defNormalProp(a, prop, b[prop]);
14
- }
15
- return a;
16
- };
17
-
18
- export {
19
- __spreadValues
20
- };
21
- //# sourceMappingURL=chunk-2MM5EJJX.mjs.map
@@ -1 +0,0 @@
1
- //# sourceMappingURL=chunk-LOY6PATI.mjs.map
@@ -1 +0,0 @@
1
- //# sourceMappingURL=chunk-MAJSPFA6.mjs.map
@@ -1 +0,0 @@
1
- //# sourceMappingURL=chunk-N6EM6ETS.mjs.map
@@ -1,13 +0,0 @@
1
- // src/math/sum.ts
2
- function sum(nums) {
3
- let result = 0;
4
- for (const num of nums) {
5
- result += num;
6
- }
7
- return result;
8
- }
9
-
10
- export {
11
- sum
12
- };
13
- //# sourceMappingURL=chunk-NOFHNJ5C.mjs.map
@@ -1,9 +0,0 @@
1
- // src/predicate/isNil.ts
2
- function isNil(x) {
3
- return x === null || x === void 0;
4
- }
5
-
6
- export {
7
- isNil
8
- };
9
- //# sourceMappingURL=chunk-OHQAR5AU.mjs.map
@@ -1 +0,0 @@
1
- //# sourceMappingURL=chunk-PMHULJNL.mjs.map