inflekt 0.7.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/esm/pluralize.js +12 -0
- package/package.json +2 -2
- package/pluralize.js +12 -0
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.7.
|
|
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) {
|