inflekt 0.5.1 → 0.6.0
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/case.d.ts +9 -26
- package/case.js +20 -50
- package/esm/case.js +16 -47
- package/package.json +4 -3
package/case.d.ts
CHANGED
|
@@ -1,16 +1,13 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Case transformation utilities
|
|
3
|
+
*
|
|
4
|
+
* Pure case transforms are delegated to komoji (the origin of truth).
|
|
5
|
+
* This module re-exports them for backward compatibility and adds
|
|
6
|
+
* inflekt-specific helpers (fixCapitalisedPlural, underscore, toScreamingSnake).
|
|
3
7
|
*/
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
*/
|
|
8
|
-
export declare function lcFirst(str: string): string;
|
|
9
|
-
/**
|
|
10
|
-
* Convert camelCase to PascalCase (uppercase first character)
|
|
11
|
-
* @example "userProfile" -> "UserProfile"
|
|
12
|
-
*/
|
|
13
|
-
export declare function ucFirst(str: string): string;
|
|
8
|
+
import { lcFirst, ucFirst, toPascalCase, toSnakeCase, toConstantCase } from 'komoji';
|
|
9
|
+
export { lcFirst, ucFirst, toPascalCase, toSnakeCase, toConstantCase };
|
|
10
|
+
export declare function toCamelCase(str: string): string;
|
|
14
11
|
/**
|
|
15
12
|
* Fix capitalized plurals that end with a number followed by 'S'
|
|
16
13
|
* This solves the issue with `blah-table1s` becoming `blahTable1S`
|
|
@@ -19,28 +16,14 @@ export declare function ucFirst(str: string): string;
|
|
|
19
16
|
export declare function fixCapitalisedPlural(str: string): string;
|
|
20
17
|
/**
|
|
21
18
|
* Convert PascalCase or camelCase to snake_case
|
|
19
|
+
* @deprecated Use toSnakeCase from komoji instead
|
|
22
20
|
* @example underscore('UserProfile') -> 'user_profile'
|
|
23
21
|
* @example underscore('userProfile') -> 'user_profile'
|
|
24
22
|
*/
|
|
25
23
|
export declare function underscore(str: string): string;
|
|
26
|
-
/**
|
|
27
|
-
* Convert a hyphenated, underscored, or already-camelCased string to camelCase.
|
|
28
|
-
* Handles both `-` and `_` delimiters.
|
|
29
|
-
* @example toCamelCase('user-profile') -> 'userProfile'
|
|
30
|
-
* @example toCamelCase('user_profile') -> 'userProfile'
|
|
31
|
-
* @example toCamelCase('UserProfile') -> 'userProfile'
|
|
32
|
-
*/
|
|
33
|
-
export declare function toCamelCase(str: string): string;
|
|
34
|
-
/**
|
|
35
|
-
* Convert a hyphenated, underscored, or already-camelCased string to PascalCase.
|
|
36
|
-
* Handles both `-` and `_` delimiters.
|
|
37
|
-
* @example toPascalCase('user-profile') -> 'UserProfile'
|
|
38
|
-
* @example toPascalCase('user_profile') -> 'UserProfile'
|
|
39
|
-
* @example toPascalCase('userProfile') -> 'UserProfile'
|
|
40
|
-
*/
|
|
41
|
-
export declare function toPascalCase(str: string): string;
|
|
42
24
|
/**
|
|
43
25
|
* Convert a camelCase or PascalCase string to SCREAMING_SNAKE_CASE.
|
|
26
|
+
* @deprecated Use toConstantCase from komoji instead
|
|
44
27
|
* @example toScreamingSnake('userProfile') -> 'USER_PROFILE'
|
|
45
28
|
* @example toScreamingSnake('UserProfile') -> 'USER_PROFILE'
|
|
46
29
|
*/
|
package/case.js
CHANGED
|
@@ -1,28 +1,27 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
/**
|
|
3
3
|
* Case transformation utilities
|
|
4
|
+
*
|
|
5
|
+
* Pure case transforms are delegated to komoji (the origin of truth).
|
|
6
|
+
* This module re-exports them for backward compatibility and adds
|
|
7
|
+
* inflekt-specific helpers (fixCapitalisedPlural, underscore, toScreamingSnake).
|
|
4
8
|
*/
|
|
5
9
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.lcFirst =
|
|
7
|
-
exports.
|
|
10
|
+
exports.toConstantCase = exports.toSnakeCase = exports.toPascalCase = exports.ucFirst = exports.lcFirst = void 0;
|
|
11
|
+
exports.toCamelCase = toCamelCase;
|
|
8
12
|
exports.fixCapitalisedPlural = fixCapitalisedPlural;
|
|
9
13
|
exports.underscore = underscore;
|
|
10
|
-
exports.toCamelCase = toCamelCase;
|
|
11
|
-
exports.toPascalCase = toPascalCase;
|
|
12
14
|
exports.toScreamingSnake = toScreamingSnake;
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
function
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
*/
|
|
24
|
-
function ucFirst(str) {
|
|
25
|
-
return str.charAt(0).toUpperCase() + str.slice(1);
|
|
15
|
+
const komoji_1 = require("komoji");
|
|
16
|
+
Object.defineProperty(exports, "lcFirst", { enumerable: true, get: function () { return komoji_1.lcFirst; } });
|
|
17
|
+
Object.defineProperty(exports, "ucFirst", { enumerable: true, get: function () { return komoji_1.ucFirst; } });
|
|
18
|
+
Object.defineProperty(exports, "toPascalCase", { enumerable: true, get: function () { return komoji_1.toPascalCase; } });
|
|
19
|
+
Object.defineProperty(exports, "toSnakeCase", { enumerable: true, get: function () { return komoji_1.toSnakeCase; } });
|
|
20
|
+
Object.defineProperty(exports, "toConstantCase", { enumerable: true, get: function () { return komoji_1.toConstantCase; } });
|
|
21
|
+
// Re-export toCamelCase — komoji's version accepts a second parameter
|
|
22
|
+
// (stripLeadingNonAlphabetChars) so we wrap to keep the simpler inflekt signature
|
|
23
|
+
function toCamelCase(str) {
|
|
24
|
+
return (0, komoji_1.toCamelCase)(str);
|
|
26
25
|
}
|
|
27
26
|
/**
|
|
28
27
|
* Fix capitalized plurals that end with a number followed by 'S'
|
|
@@ -34,48 +33,19 @@ function fixCapitalisedPlural(str) {
|
|
|
34
33
|
}
|
|
35
34
|
/**
|
|
36
35
|
* Convert PascalCase or camelCase to snake_case
|
|
36
|
+
* @deprecated Use toSnakeCase from komoji instead
|
|
37
37
|
* @example underscore('UserProfile') -> 'user_profile'
|
|
38
38
|
* @example underscore('userProfile') -> 'user_profile'
|
|
39
39
|
*/
|
|
40
40
|
function underscore(str) {
|
|
41
|
-
return str
|
|
42
|
-
.replace(/([A-Z])/g, '_$1')
|
|
43
|
-
.replace(/^_/, '')
|
|
44
|
-
.toLowerCase();
|
|
45
|
-
}
|
|
46
|
-
/**
|
|
47
|
-
* Convert a hyphenated, underscored, or already-camelCased string to camelCase.
|
|
48
|
-
* Handles both `-` and `_` delimiters.
|
|
49
|
-
* @example toCamelCase('user-profile') -> 'userProfile'
|
|
50
|
-
* @example toCamelCase('user_profile') -> 'userProfile'
|
|
51
|
-
* @example toCamelCase('UserProfile') -> 'userProfile'
|
|
52
|
-
*/
|
|
53
|
-
function toCamelCase(str) {
|
|
54
|
-
return str
|
|
55
|
-
.replace(/[-_](.)/g, (_, char) => char.toUpperCase())
|
|
56
|
-
.replace(/^(.)/, (_, char) => char.toLowerCase());
|
|
57
|
-
}
|
|
58
|
-
/**
|
|
59
|
-
* Convert a hyphenated, underscored, or already-camelCased string to PascalCase.
|
|
60
|
-
* Handles both `-` and `_` delimiters.
|
|
61
|
-
* @example toPascalCase('user-profile') -> 'UserProfile'
|
|
62
|
-
* @example toPascalCase('user_profile') -> 'UserProfile'
|
|
63
|
-
* @example toPascalCase('userProfile') -> 'UserProfile'
|
|
64
|
-
*/
|
|
65
|
-
function toPascalCase(str) {
|
|
66
|
-
return str
|
|
67
|
-
.replace(/[-_](.)/g, (_, char) => char.toUpperCase())
|
|
68
|
-
.replace(/^(.)/, (_, char) => char.toUpperCase());
|
|
41
|
+
return (0, komoji_1.toSnakeCase)(str);
|
|
69
42
|
}
|
|
70
43
|
/**
|
|
71
44
|
* Convert a camelCase or PascalCase string to SCREAMING_SNAKE_CASE.
|
|
45
|
+
* @deprecated Use toConstantCase from komoji instead
|
|
72
46
|
* @example toScreamingSnake('userProfile') -> 'USER_PROFILE'
|
|
73
47
|
* @example toScreamingSnake('UserProfile') -> 'USER_PROFILE'
|
|
74
48
|
*/
|
|
75
49
|
function toScreamingSnake(str) {
|
|
76
|
-
return str
|
|
77
|
-
.replace(/([A-Z])/g, '_$1')
|
|
78
|
-
.replace(/[-\s]/g, '_')
|
|
79
|
-
.toUpperCase()
|
|
80
|
-
.replace(/^_/, '');
|
|
50
|
+
return (0, komoji_1.toConstantCase)(str);
|
|
81
51
|
}
|
package/esm/case.js
CHANGED
|
@@ -1,19 +1,17 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Case transformation utilities
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
*
|
|
6
|
-
*
|
|
7
|
-
*/
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
export function ucFirst(str) {
|
|
16
|
-
return str.charAt(0).toUpperCase() + str.slice(1);
|
|
3
|
+
*
|
|
4
|
+
* Pure case transforms are delegated to komoji (the origin of truth).
|
|
5
|
+
* This module re-exports them for backward compatibility and adds
|
|
6
|
+
* inflekt-specific helpers (fixCapitalisedPlural, underscore, toScreamingSnake).
|
|
7
|
+
*/
|
|
8
|
+
import { lcFirst, ucFirst, toCamelCase as _toCamelCase, toPascalCase, toSnakeCase, toConstantCase, } from 'komoji';
|
|
9
|
+
// Re-export komoji functions directly
|
|
10
|
+
export { lcFirst, ucFirst, toPascalCase, toSnakeCase, toConstantCase };
|
|
11
|
+
// Re-export toCamelCase — komoji's version accepts a second parameter
|
|
12
|
+
// (stripLeadingNonAlphabetChars) so we wrap to keep the simpler inflekt signature
|
|
13
|
+
export function toCamelCase(str) {
|
|
14
|
+
return _toCamelCase(str);
|
|
17
15
|
}
|
|
18
16
|
/**
|
|
19
17
|
* Fix capitalized plurals that end with a number followed by 'S'
|
|
@@ -25,48 +23,19 @@ export function fixCapitalisedPlural(str) {
|
|
|
25
23
|
}
|
|
26
24
|
/**
|
|
27
25
|
* Convert PascalCase or camelCase to snake_case
|
|
26
|
+
* @deprecated Use toSnakeCase from komoji instead
|
|
28
27
|
* @example underscore('UserProfile') -> 'user_profile'
|
|
29
28
|
* @example underscore('userProfile') -> 'user_profile'
|
|
30
29
|
*/
|
|
31
30
|
export function underscore(str) {
|
|
32
|
-
return str
|
|
33
|
-
.replace(/([A-Z])/g, '_$1')
|
|
34
|
-
.replace(/^_/, '')
|
|
35
|
-
.toLowerCase();
|
|
36
|
-
}
|
|
37
|
-
/**
|
|
38
|
-
* Convert a hyphenated, underscored, or already-camelCased string to camelCase.
|
|
39
|
-
* Handles both `-` and `_` delimiters.
|
|
40
|
-
* @example toCamelCase('user-profile') -> 'userProfile'
|
|
41
|
-
* @example toCamelCase('user_profile') -> 'userProfile'
|
|
42
|
-
* @example toCamelCase('UserProfile') -> 'userProfile'
|
|
43
|
-
*/
|
|
44
|
-
export function toCamelCase(str) {
|
|
45
|
-
return str
|
|
46
|
-
.replace(/[-_](.)/g, (_, char) => char.toUpperCase())
|
|
47
|
-
.replace(/^(.)/, (_, char) => char.toLowerCase());
|
|
48
|
-
}
|
|
49
|
-
/**
|
|
50
|
-
* Convert a hyphenated, underscored, or already-camelCased string to PascalCase.
|
|
51
|
-
* Handles both `-` and `_` delimiters.
|
|
52
|
-
* @example toPascalCase('user-profile') -> 'UserProfile'
|
|
53
|
-
* @example toPascalCase('user_profile') -> 'UserProfile'
|
|
54
|
-
* @example toPascalCase('userProfile') -> 'UserProfile'
|
|
55
|
-
*/
|
|
56
|
-
export function toPascalCase(str) {
|
|
57
|
-
return str
|
|
58
|
-
.replace(/[-_](.)/g, (_, char) => char.toUpperCase())
|
|
59
|
-
.replace(/^(.)/, (_, char) => char.toUpperCase());
|
|
31
|
+
return toSnakeCase(str);
|
|
60
32
|
}
|
|
61
33
|
/**
|
|
62
34
|
* Convert a camelCase or PascalCase string to SCREAMING_SNAKE_CASE.
|
|
35
|
+
* @deprecated Use toConstantCase from komoji instead
|
|
63
36
|
* @example toScreamingSnake('userProfile') -> 'USER_PROFILE'
|
|
64
37
|
* @example toScreamingSnake('UserProfile') -> 'USER_PROFILE'
|
|
65
38
|
*/
|
|
66
39
|
export function toScreamingSnake(str) {
|
|
67
|
-
return str
|
|
68
|
-
.replace(/([A-Z])/g, '_$1')
|
|
69
|
-
.replace(/[-\s]/g, '_')
|
|
70
|
-
.toUpperCase()
|
|
71
|
-
.replace(/^_/, '');
|
|
40
|
+
return toConstantCase(str);
|
|
72
41
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "inflekt",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.6.0",
|
|
4
4
|
"description": "Inflection utilities for pluralization and singularization with PostGraphile-compatible Latin suffix handling",
|
|
5
5
|
"author": "Constructive <developers@constructive.io>",
|
|
6
6
|
"homepage": "https://github.com/constructive-io/dev-utils",
|
|
@@ -41,7 +41,8 @@
|
|
|
41
41
|
"makage": "0.1.10"
|
|
42
42
|
},
|
|
43
43
|
"dependencies": {
|
|
44
|
-
"inflection": "^3.0.0"
|
|
44
|
+
"inflection": "^3.0.0",
|
|
45
|
+
"komoji": "0.9.0"
|
|
45
46
|
},
|
|
46
|
-
"gitHead": "
|
|
47
|
+
"gitHead": "db30bc2755067006e1d6b6e36e84312a3953f033"
|
|
47
48
|
}
|