es-toolkit 1.10.1-dev.229 → 1.10.1-dev.231
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.
- package/dist/array/index.mjs +31 -31
- package/dist/chunk-54TK5BIS.mjs +1 -0
- package/dist/chunk-GL7PPRA4.mjs +25 -0
- package/dist/chunk-GL7PPRA4.mjs.map +1 -0
- package/dist/chunk-MJA7DAOJ.mjs +25 -0
- package/dist/chunk-MJA7DAOJ.mjs.map +1 -0
- package/dist/chunk-XT74R35S.mjs +1 -0
- package/dist/compat/index.d.mts +2 -0
- package/dist/compat/index.d.ts +2 -0
- package/dist/compat/index.js +42 -0
- package/dist/compat/index.js.map +1 -1
- package/dist/compat/index.mjs +66 -58
- package/dist/compat/index.mjs.map +1 -1
- package/dist/function/index.mjs +6 -6
- package/dist/index.d.mts +2 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.js +42 -0
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +66 -58
- package/dist/object/index.d.mts +1 -0
- package/dist/object/index.d.ts +1 -0
- package/dist/object/index.js +25 -2
- package/dist/object/index.js.map +1 -1
- package/dist/object/index.mjs +6 -2
- package/dist/object/set.d.mts +32 -0
- package/dist/object/set.d.ts +32 -0
- package/dist/object/set.js +49 -0
- package/dist/object/set.js.map +1 -0
- package/dist/object/set.mjs +8 -0
- package/dist/object/set.mjs.map +1 -0
- package/dist/string/index.d.mts +1 -0
- package/dist/string/index.d.ts +1 -0
- package/dist/string/index.js +21 -2
- package/dist/string/index.js.map +1 -1
- package/dist/string/index.mjs +6 -2
- package/dist/string/startCase.d.mts +16 -0
- package/dist/string/startCase.d.ts +16 -0
- package/dist/string/startCase.js +54 -0
- package/dist/string/startCase.js.map +1 -0
- package/dist/string/startCase.mjs +9 -0
- package/dist/string/startCase.mjs.map +1 -0
- package/package.json +1 -1
- package/dist/chunk-OSOLEQLZ.mjs +0 -1
- package/dist/chunk-QKYYOLJ6.mjs +0 -1
- /package/dist/{chunk-OSOLEQLZ.mjs.map → chunk-54TK5BIS.mjs.map} +0 -0
- /package/dist/{chunk-QKYYOLJ6.mjs.map → chunk-XT74R35S.mjs.map} +0 -0
|
@@ -0,0 +1,54 @@
|
|
|
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/startCase.ts
|
|
21
|
+
var startCase_exports = {};
|
|
22
|
+
__export(startCase_exports, {
|
|
23
|
+
startCase: () => startCase
|
|
24
|
+
});
|
|
25
|
+
module.exports = __toCommonJS(startCase_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/startCase.ts
|
|
35
|
+
function startCase(str) {
|
|
36
|
+
const words = getWords(str.trim());
|
|
37
|
+
let result = "";
|
|
38
|
+
for (const word of words) {
|
|
39
|
+
if (result) {
|
|
40
|
+
result += " ";
|
|
41
|
+
}
|
|
42
|
+
if (word === word.toUpperCase()) {
|
|
43
|
+
result += word;
|
|
44
|
+
} else {
|
|
45
|
+
result += word[0].toUpperCase() + word.slice(1).toLowerCase();
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
return result;
|
|
49
|
+
}
|
|
50
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
51
|
+
0 && (module.exports = {
|
|
52
|
+
startCase
|
|
53
|
+
});
|
|
54
|
+
//# sourceMappingURL=startCase.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/string/startCase.ts","../../src/string/_internal/getWords.ts"],"sourcesContent":["import { getWords } from './_internal/getWords';\n\n/**\n * Converts the first character of each word in a string to uppercase and the remaining characters to lowercase.\n *\n * Start case is the naming convention in which each word is written with an initial capital letter.\n * @param {string} str - The string to convert.\n * @returns {string} The converted string.\n *\n * @example\n * const result1 = startCase('hello world'); // result will be 'Hello World'\n * const result2 = startCase('HELLO WORLD'); // result will be 'Hello World'\n * const result3 = startCase('hello-world'); // result will be 'Hello World'\n * const result4 = startCase('hello_world'); // result will be 'Hello World'\n */\nexport function startCase(str: string): string {\n const words = getWords(str.trim());\n let result = '';\n for (const word of words) {\n if (result) {\n result += ' ';\n }\n if (word === word.toUpperCase()) {\n result += word;\n } else {\n result += word[0].toUpperCase() + word.slice(1).toLowerCase();\n }\n }\n return result;\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;;;ADLO,SAAS,UAAU,KAAqB;AAC7C,QAAM,QAAQ,SAAS,IAAI,KAAK,CAAC;AACjC,MAAI,SAAS;AACb,aAAW,QAAQ,OAAO;AACxB,QAAI,QAAQ;AACV,gBAAU;AAAA,IACZ;AACA,QAAI,SAAS,KAAK,YAAY,GAAG;AAC/B,gBAAU;AAAA,IACZ,OAAO;AACL,gBAAU,KAAK,CAAC,EAAE,YAAY,IAAI,KAAK,MAAM,CAAC,EAAE,YAAY;AAAA,IAC9D;AAAA,EACF;AACA,SAAO;AACT;","names":[]}
|
|
@@ -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.10.1-dev.
|
|
4
|
+
"version": "1.10.1-dev.231+b9432e1c",
|
|
5
5
|
"homepage": "https://es-toolkit.slash.page",
|
|
6
6
|
"bugs": "https://github.com/toss/es-toolkit/issues",
|
|
7
7
|
"repository": {
|
package/dist/chunk-OSOLEQLZ.mjs
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
//# sourceMappingURL=chunk-OSOLEQLZ.mjs.map
|
package/dist/chunk-QKYYOLJ6.mjs
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
//# sourceMappingURL=chunk-QKYYOLJ6.mjs.map
|
|
File without changes
|
|
File without changes
|