inflekt 0.6.0 → 0.7.1
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 +2 -2
- package/case.js +2 -1
- package/esm/case.js +2 -2
- package/esm/pluralize.js +12 -0
- package/package.json +2 -2
- package/pluralize.js +12 -0
package/case.d.ts
CHANGED
|
@@ -5,8 +5,8 @@
|
|
|
5
5
|
* This module re-exports them for backward compatibility and adds
|
|
6
6
|
* inflekt-specific helpers (fixCapitalisedPlural, underscore, toScreamingSnake).
|
|
7
7
|
*/
|
|
8
|
-
import { lcFirst, ucFirst, toPascalCase, toSnakeCase, toConstantCase } from 'komoji';
|
|
9
|
-
export { lcFirst, ucFirst, toPascalCase, toSnakeCase, toConstantCase };
|
|
8
|
+
import { lcFirst, ucFirst, toPascalCase, toSnakeCase, toKebabCase, toConstantCase } from 'komoji';
|
|
9
|
+
export { lcFirst, ucFirst, toPascalCase, toSnakeCase, toKebabCase, toConstantCase };
|
|
10
10
|
export declare function toCamelCase(str: string): string;
|
|
11
11
|
/**
|
|
12
12
|
* Fix capitalized plurals that end with a number followed by 'S'
|
package/case.js
CHANGED
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
* inflekt-specific helpers (fixCapitalisedPlural, underscore, toScreamingSnake).
|
|
8
8
|
*/
|
|
9
9
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
10
|
-
exports.toConstantCase = exports.toSnakeCase = exports.toPascalCase = exports.ucFirst = exports.lcFirst = void 0;
|
|
10
|
+
exports.toConstantCase = exports.toKebabCase = exports.toSnakeCase = exports.toPascalCase = exports.ucFirst = exports.lcFirst = void 0;
|
|
11
11
|
exports.toCamelCase = toCamelCase;
|
|
12
12
|
exports.fixCapitalisedPlural = fixCapitalisedPlural;
|
|
13
13
|
exports.underscore = underscore;
|
|
@@ -17,6 +17,7 @@ Object.defineProperty(exports, "lcFirst", { enumerable: true, get: function () {
|
|
|
17
17
|
Object.defineProperty(exports, "ucFirst", { enumerable: true, get: function () { return komoji_1.ucFirst; } });
|
|
18
18
|
Object.defineProperty(exports, "toPascalCase", { enumerable: true, get: function () { return komoji_1.toPascalCase; } });
|
|
19
19
|
Object.defineProperty(exports, "toSnakeCase", { enumerable: true, get: function () { return komoji_1.toSnakeCase; } });
|
|
20
|
+
Object.defineProperty(exports, "toKebabCase", { enumerable: true, get: function () { return komoji_1.toKebabCase; } });
|
|
20
21
|
Object.defineProperty(exports, "toConstantCase", { enumerable: true, get: function () { return komoji_1.toConstantCase; } });
|
|
21
22
|
// Re-export toCamelCase — komoji's version accepts a second parameter
|
|
22
23
|
// (stripLeadingNonAlphabetChars) so we wrap to keep the simpler inflekt signature
|
package/esm/case.js
CHANGED
|
@@ -5,9 +5,9 @@
|
|
|
5
5
|
* This module re-exports them for backward compatibility and adds
|
|
6
6
|
* inflekt-specific helpers (fixCapitalisedPlural, underscore, toScreamingSnake).
|
|
7
7
|
*/
|
|
8
|
-
import { lcFirst, ucFirst, toCamelCase as _toCamelCase, toPascalCase, toSnakeCase, toConstantCase, } from 'komoji';
|
|
8
|
+
import { lcFirst, ucFirst, toCamelCase as _toCamelCase, toPascalCase, toSnakeCase, toKebabCase, toConstantCase, } from 'komoji';
|
|
9
9
|
// Re-export komoji functions directly
|
|
10
|
-
export { lcFirst, ucFirst, toPascalCase, toSnakeCase, toConstantCase };
|
|
10
|
+
export { lcFirst, ucFirst, toPascalCase, toSnakeCase, toKebabCase, toConstantCase };
|
|
11
11
|
// Re-export toCamelCase — komoji's version accepts a second parameter
|
|
12
12
|
// (stripLeadingNonAlphabetChars) so we wrap to keep the simpler inflekt signature
|
|
13
13
|
export function toCamelCase(str) {
|
package/esm/pluralize.js
CHANGED
|
@@ -23,6 +23,12 @@ const LATIN_SUFFIX_OVERRIDES = [
|
|
|
23
23
|
['curricula', 'curriculum'],
|
|
24
24
|
['data', 'datum'],
|
|
25
25
|
];
|
|
26
|
+
/**
|
|
27
|
+
* Compound words ending in "base" that the inflection library incorrectly
|
|
28
|
+
* singularizes via its (b)a branch in the ses$ rule (e.g. codebases -> codebasis).
|
|
29
|
+
* We intercept these before delegating to inflection.singularize().
|
|
30
|
+
*/
|
|
31
|
+
const COMPOUND_BASE_REGEX = /(database|codebase|firebase|knowledgebase)s$/i;
|
|
26
32
|
const TRAILING_TRIPLE_S_REGEX = /[sS]{3,}$/;
|
|
27
33
|
const TRAILING_TRIPLE_S_BEFORE_ES_REGEX = /[sS]{3,}(?=e[sS]$)/;
|
|
28
34
|
function normalizeTrailingSRun(suffix) {
|
|
@@ -81,6 +87,12 @@ export function singularize(word) {
|
|
|
81
87
|
return prefix + newSuffix;
|
|
82
88
|
}
|
|
83
89
|
}
|
|
90
|
+
// Compound *base words: the inflection library's (b)a branch in the ses$
|
|
91
|
+
// rule incorrectly produces "codebasis" instead of "codebase".
|
|
92
|
+
const baseMatch = normalizedWord.match(COMPOUND_BASE_REGEX);
|
|
93
|
+
if (baseMatch) {
|
|
94
|
+
return normalizedWord.slice(0, -1);
|
|
95
|
+
}
|
|
84
96
|
return normalizeMalformedDoubleS(inflection.singularize(normalizedWord));
|
|
85
97
|
}
|
|
86
98
|
function pluralizeCanonical(word) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "inflekt",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.7.1",
|
|
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",
|
|
@@ -44,5 +44,5 @@
|
|
|
44
44
|
"inflection": "^3.0.0",
|
|
45
45
|
"komoji": "0.9.0"
|
|
46
46
|
},
|
|
47
|
-
"gitHead": "
|
|
47
|
+
"gitHead": "b1d40ce4679e16557e3caa188e06059e2dc5f4d8"
|
|
48
48
|
}
|
package/pluralize.js
CHANGED
|
@@ -64,6 +64,12 @@ const LATIN_SUFFIX_OVERRIDES = [
|
|
|
64
64
|
['curricula', 'curriculum'],
|
|
65
65
|
['data', 'datum'],
|
|
66
66
|
];
|
|
67
|
+
/**
|
|
68
|
+
* Compound words ending in "base" that the inflection library incorrectly
|
|
69
|
+
* singularizes via its (b)a branch in the ses$ rule (e.g. codebases -> codebasis).
|
|
70
|
+
* We intercept these before delegating to inflection.singularize().
|
|
71
|
+
*/
|
|
72
|
+
const COMPOUND_BASE_REGEX = /(database|codebase|firebase|knowledgebase)s$/i;
|
|
67
73
|
const TRAILING_TRIPLE_S_REGEX = /[sS]{3,}$/;
|
|
68
74
|
const TRAILING_TRIPLE_S_BEFORE_ES_REGEX = /[sS]{3,}(?=e[sS]$)/;
|
|
69
75
|
function normalizeTrailingSRun(suffix) {
|
|
@@ -122,6 +128,12 @@ function singularize(word) {
|
|
|
122
128
|
return prefix + newSuffix;
|
|
123
129
|
}
|
|
124
130
|
}
|
|
131
|
+
// Compound *base words: the inflection library's (b)a branch in the ses$
|
|
132
|
+
// rule incorrectly produces "codebasis" instead of "codebase".
|
|
133
|
+
const baseMatch = normalizedWord.match(COMPOUND_BASE_REGEX);
|
|
134
|
+
if (baseMatch) {
|
|
135
|
+
return normalizedWord.slice(0, -1);
|
|
136
|
+
}
|
|
125
137
|
return normalizeMalformedDoubleS(inflection.singularize(normalizedWord));
|
|
126
138
|
}
|
|
127
139
|
function pluralizeCanonical(word) {
|