caseforge 0.1.1 → 0.1.2
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/index.js +28 -4
- package/package.json +5 -2
package/dist/index.js
CHANGED
|
@@ -45,28 +45,52 @@ function camelCaseString(str) {
|
|
|
45
45
|
return str.replace(PATTERNS.LEADING_UPPER, (char) => char.toLowerCase()).replace(PATTERNS.SEPARATOR_WITH_CHAR, (_, char) => char.toUpperCase()).replace(PATTERNS.EDGE_SEPARATORS, "");
|
|
46
46
|
}
|
|
47
47
|
function toCamelCase(input) {
|
|
48
|
-
|
|
48
|
+
if (isString(input)) {
|
|
49
|
+
return camelCaseString(input);
|
|
50
|
+
}
|
|
51
|
+
if (isObject(input)) {
|
|
52
|
+
return transformObject(input, camelCaseString);
|
|
53
|
+
}
|
|
54
|
+
return input;
|
|
49
55
|
}
|
|
50
56
|
// src/core/toKebabCase.ts
|
|
51
57
|
function kebabCaseString(str) {
|
|
52
58
|
return str.replace(PATTERNS.UPPERCASE, (char) => `-${char.toLowerCase()}`).replace(PATTERNS.CONSECUTIVE_SEPARATORS, "-").replace(PATTERNS.EDGE_SEPARATORS, "");
|
|
53
59
|
}
|
|
54
60
|
function toKebabCase(input) {
|
|
55
|
-
|
|
61
|
+
if (isString(input)) {
|
|
62
|
+
return kebabCaseString(input);
|
|
63
|
+
}
|
|
64
|
+
if (isObject(input)) {
|
|
65
|
+
return transformObject(input, kebabCaseString);
|
|
66
|
+
}
|
|
67
|
+
return input;
|
|
56
68
|
}
|
|
57
69
|
// src/core/toPascalCase.ts
|
|
58
70
|
function pascalCaseString(str) {
|
|
59
71
|
return str.replace(PATTERNS.SEPARATOR_WITH_CHAR, (_, char) => char.toUpperCase()).replace(PATTERNS.EDGE_SEPARATORS, "").replace(PATTERNS.LEADING_LOWER, (char) => char.toUpperCase());
|
|
60
72
|
}
|
|
61
73
|
function toPascalCase(input) {
|
|
62
|
-
|
|
74
|
+
if (isString(input)) {
|
|
75
|
+
return pascalCaseString(input);
|
|
76
|
+
}
|
|
77
|
+
if (isObject(input)) {
|
|
78
|
+
return transformObject(input, pascalCaseString);
|
|
79
|
+
}
|
|
80
|
+
return input;
|
|
63
81
|
}
|
|
64
82
|
// src/core/toSnakeCase.ts
|
|
65
83
|
function snakeCaseString(str) {
|
|
66
84
|
return str.replace(PATTERNS.UPPERCASE, (char) => `_${char.toLowerCase()}`).replace(PATTERNS.CONSECUTIVE_SEPARATORS, "_").replace(PATTERNS.EDGE_SEPARATORS, "");
|
|
67
85
|
}
|
|
68
86
|
function toSnakeCase(input) {
|
|
69
|
-
|
|
87
|
+
if (isString(input)) {
|
|
88
|
+
return snakeCaseString(input);
|
|
89
|
+
}
|
|
90
|
+
if (isObject(input)) {
|
|
91
|
+
return transformObject(input, snakeCaseString);
|
|
92
|
+
}
|
|
93
|
+
return input;
|
|
70
94
|
}
|
|
71
95
|
export {
|
|
72
96
|
toSnakeCase,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "caseforge",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.2",
|
|
4
4
|
"description": "caseforge - Effortlessly convert between snake_case, camelCase, and more in TypeScript. Zero dependencies, type-safe, and easy to use for any project.",
|
|
5
5
|
"main": "./dist/index.js",
|
|
6
6
|
"types": "./dist/index.d.ts",
|
|
@@ -24,7 +24,10 @@
|
|
|
24
24
|
"scripts": {
|
|
25
25
|
"build": "bun x tsc --emitDeclarationOnly && bun build src/index.ts --outdir dist --target node",
|
|
26
26
|
"check": "bunx @biomejs/biome check --write src && bun x tsc --noEmit",
|
|
27
|
-
"prepublishOnly": "bun run check && bun test && bun run build"
|
|
27
|
+
"prepublishOnly": "bun run check && bun test && bun run build",
|
|
28
|
+
"release:patch": "npm version patch && git push && git push --tags && npm publish",
|
|
29
|
+
"release:minor": "npm version minor && git push && git push --tags && npm publish",
|
|
30
|
+
"release:major": "npm version major && git push && git push --tags && npm publish"
|
|
28
31
|
},
|
|
29
32
|
"keywords": [
|
|
30
33
|
"typescript",
|