caseforge 0.5.1 → 0.5.3
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 +1 -1
- package/dist/utils/caseGuards.d.ts +1 -1
- package/dist/utils/patterns.d.ts +3 -3
- package/dist/utils/transform.d.ts +7 -0
- package/package.json +56 -56
package/dist/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
var
|
|
1
|
+
var C={LEADING_UPPER:/^[A-Z]/,UPPER_CHAR:/[A-Z]/g,LEADING_LOWER:/^[a-z]/,SEPARATOR_WITH_CHAR:/[_-]+(.)/g,EDGE_SEPARATORS:/^[_-]+|[_-]+$/g,CONSECUTIVE_SEPARATORS:/[_-]+/g,CAMEL_CASE:/^[a-z][a-zA-Z0-9]*$/,KEBAB_CASE:/^[a-z][a-z0-9-]*$/,PASCAL_CASE:/^[A-Z][a-zA-Z0-9]*$/,SNAKE_CASE:/^[a-z][a-z0-9_]*$/,UPPER_CASE:/^[A-Z][A-Z0-9_]*$/};function H(x){return typeof x==="string"}function Q(x){return Array.isArray(x)}function V(x){return typeof x==="object"&&x!==null&&!Q(x)}function W(x){return x instanceof Date||x instanceof RegExp||typeof x==="function"}function z(x,q){if(H(x))return q(x);if(Q(x))return x.map((D)=>z(D,q));if(V(x))return X(x,q);return x}function X(x,q){let D={};for(let[Y,J]of Object.entries(x)){let L=q(Y);if(W(J))D[L]=J;else if(Q(J))D[L]=J.map((Z)=>z(Z,q));else if(V(J))D[L]=X(J,q);else D[L]=J}return D}function $(x){return x.replace(C.LEADING_UPPER,(q)=>q.toLowerCase()).replace(C.SEPARATOR_WITH_CHAR,(q,D)=>D.toUpperCase()).replace(C.EDGE_SEPARATORS,"")}function B(x){return z(x,$)}function F(x){return x.replace(C.UPPER_CHAR,(q)=>`-${q.toLowerCase()}`).replace(C.CONSECUTIVE_SEPARATORS,"-").replace(C.EDGE_SEPARATORS,"")}function M(x){return z(x,F)}function U(x){return x.replace(C.SEPARATOR_WITH_CHAR,(q,D)=>D.toUpperCase()).replace(C.EDGE_SEPARATORS,"").replace(C.LEADING_LOWER,(q)=>q.toUpperCase())}function d(x){return z(x,U)}function G(x){return x.replace(C.UPPER_CHAR,(q)=>`_${q.toLowerCase()}`).replace(C.CONSECUTIVE_SEPARATORS,"_").replace(C.EDGE_SEPARATORS,"")}function O(x){return z(x,G)}function w(x){return x.replace(C.UPPER_CHAR,(q)=>`_${q.toLowerCase()}`).replace(C.CONSECUTIVE_SEPARATORS,"_").replace(C.EDGE_SEPARATORS,"").toUpperCase()}function K(x){return z(x,w)}function I(x){if(!H(x))return!1;return C.CAMEL_CASE.test(x)}function y(x){if(!H(x))return!1;return C.SNAKE_CASE.test(x)}function _(x){if(!H(x))return!1;return C.KEBAB_CASE.test(x)}function k(x){if(!H(x))return!1;return C.PASCAL_CASE.test(x)}function N(x){if(!H(x))return!1;return C.UPPER_CASE.test(x)}export{K as toUpperCase,O as toSnakeCase,d as toPascalCase,M as toKebabCase,B as toCamelCase,N as isUpperCase,y as isSnakeCase,k as isPascalCase,_ as isKebabCase,I as isCamelCase};
|
|
@@ -25,6 +25,6 @@ export declare function isPascalCase(value: unknown): boolean;
|
|
|
25
25
|
/**
|
|
26
26
|
* Checks if a string is in UPPER_SNAKE_CASE format.
|
|
27
27
|
* @param value - The value to check.
|
|
28
|
-
* @returns `true` if the value is in
|
|
28
|
+
* @returns `true` if the value is in UPPER_CASE format, `false` otherwise.
|
|
29
29
|
*/
|
|
30
30
|
export declare function isUpperCase(value: unknown): boolean;
|
package/dist/utils/patterns.d.ts
CHANGED
|
@@ -4,8 +4,8 @@
|
|
|
4
4
|
export declare const PATTERNS: {
|
|
5
5
|
/** Matches a leading uppercase letter */
|
|
6
6
|
readonly LEADING_UPPER: RegExp;
|
|
7
|
-
/** Matches
|
|
8
|
-
readonly
|
|
7
|
+
/** Matches a single uppercase letter */
|
|
8
|
+
readonly UPPER_CHAR: RegExp;
|
|
9
9
|
/** Matches a leading lowercase letter */
|
|
10
10
|
readonly LEADING_LOWER: RegExp;
|
|
11
11
|
/** Matches separators (_-) followed by any character */
|
|
@@ -23,5 +23,5 @@ export declare const PATTERNS: {
|
|
|
23
23
|
/** Matches a complete snake_case string */
|
|
24
24
|
readonly SNAKE_CASE: RegExp;
|
|
25
25
|
/** Matches a complete UPPER_SNAKE_CASE string */
|
|
26
|
-
readonly
|
|
26
|
+
readonly UPPER_CASE: RegExp;
|
|
27
27
|
};
|
|
@@ -1,3 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Converts an unknown value to the desired case.
|
|
3
|
+
* @param input - The input value to convert.
|
|
4
|
+
* @param convertString - Function to convert a string to the desired case.
|
|
5
|
+
* @returns The converted value.
|
|
6
|
+
*/
|
|
7
|
+
export declare function convertInput(input: unknown, convertString: (str: string) => string): unknown;
|
|
1
8
|
/**
|
|
2
9
|
* Generic object key transformation.
|
|
3
10
|
* @param object - The object to transform.
|
package/package.json
CHANGED
|
@@ -1,58 +1,58 @@
|
|
|
1
1
|
{
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
2
|
+
"name": "caseforge",
|
|
3
|
+
"version": "0.5.3",
|
|
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
|
+
"main": "./dist/index.js",
|
|
6
|
+
"types": "./dist/index.d.ts",
|
|
7
|
+
"repository": {
|
|
8
|
+
"type": "git",
|
|
9
|
+
"url": "https://github.com/chikadahiroki/caseforge.git"
|
|
10
|
+
},
|
|
11
|
+
"bugs": {
|
|
12
|
+
"url": "https://github.com/chikadahiroki/caseforge/issues"
|
|
13
|
+
},
|
|
14
|
+
"homepage": "https://github.com/chikadahiroki/caseforge#readme",
|
|
15
|
+
"exports": {
|
|
16
|
+
".": {
|
|
17
|
+
"import": {
|
|
18
|
+
"types": "./dist/index.d.ts",
|
|
19
|
+
"default": "./dist/index.js"
|
|
20
|
+
},
|
|
21
|
+
"require": {
|
|
22
|
+
"types": "./dist/index.d.ts",
|
|
23
|
+
"default": "./dist/index.js"
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
},
|
|
27
|
+
"files": [
|
|
28
|
+
"dist",
|
|
29
|
+
"README.md",
|
|
30
|
+
"LICENSE"
|
|
31
|
+
],
|
|
32
|
+
"scripts": {
|
|
33
|
+
"build": "bunx tsc --emitDeclarationOnly && bun build src/index.ts --outdir dist --target node --minify",
|
|
34
|
+
"check": "bunx @biomejs/biome check --write && bun x tsc --noEmit",
|
|
35
|
+
"release:patch:auto": "npm version patch && git push && git push --tags && gh release create v$(node -p 'require(\"./package.json\").version') --generate-notes",
|
|
36
|
+
"release:minor:auto": "npm version minor && git push && git push --tags && gh release create v$(node -p 'require(\"./package.json\").version') --generate-notes",
|
|
37
|
+
"release:major:auto": "npm version major && git push && git push --tags && gh release create v$(node -p 'require(\"./package.json\").version') --generate-notes"
|
|
38
|
+
},
|
|
39
|
+
"keywords": [
|
|
40
|
+
"typescript",
|
|
41
|
+
"caseforge",
|
|
42
|
+
"case-conversion",
|
|
43
|
+
"camelcase",
|
|
44
|
+
"snake-case",
|
|
45
|
+
"kebab-case",
|
|
46
|
+
"type-safe",
|
|
47
|
+
"utility",
|
|
48
|
+
"transform"
|
|
49
|
+
],
|
|
50
|
+
"author": "Chikada Hiroki",
|
|
51
|
+
"license": "MIT",
|
|
52
|
+
"devDependencies": {
|
|
53
|
+
"@biomejs/biome": "2.4.6",
|
|
54
|
+
"@types/bun": "^1.3.10",
|
|
55
|
+
"lefthook": "^2.1.3",
|
|
56
|
+
"typescript": "^5.9.3"
|
|
57
|
+
}
|
|
58
58
|
}
|