@bccampus/utils 0.1.1 → 0.2.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.
Files changed (72) hide show
  1. package/dist/array/chunk.cjs +9 -0
  2. package/dist/array/index.cjs +4 -0
  3. package/dist/date/index.cjs +8 -0
  4. package/dist/date/iso-date-time.cjs +256 -0
  5. package/dist/duration/add-durations.cjs +12 -0
  6. package/dist/duration/index.cjs +8 -0
  7. package/dist/duration/is-duration.cjs +7 -0
  8. package/dist/duration/to-number.cjs +14 -0
  9. package/dist/format/formatter.cjs +40 -0
  10. package/dist/format/index.cjs +13 -0
  11. package/dist/format/stringify.cjs +42 -0
  12. package/dist/format/template.cjs +35 -0
  13. package/dist/object/get.cjs +7 -0
  14. package/dist/object/index.cjs +12 -0
  15. package/dist/object/is-object.cjs +4 -0
  16. package/dist/object/omit.cjs +18 -0
  17. package/dist/object/pick.cjs +11 -0
  18. package/dist/object/set.cjs +14 -0
  19. package/dist/path/file-url-to-path.cjs +10 -0
  20. package/dist/path/file-url-to-path.d.ts +4 -0
  21. package/dist/path/file-url-to-path.js +10 -0
  22. package/dist/path/index.cjs +6 -0
  23. package/dist/path/index.d.ts +2 -0
  24. package/dist/path/index.js +6 -0
  25. package/dist/path/normalize.cjs +32 -0
  26. package/dist/path/normalize.d.ts +31 -0
  27. package/dist/path/normalize.js +32 -0
  28. package/dist/set/difference.cjs +10 -0
  29. package/dist/set/index.cjs +12 -0
  30. package/dist/set/intersection.cjs +13 -0
  31. package/dist/set/is-superset.cjs +12 -0
  32. package/dist/set/symmetric-difference.cjs +14 -0
  33. package/dist/set/union.cjs +10 -0
  34. package/dist/string/capitalize.cjs +4 -0
  35. package/dist/string/index.cjs +14 -0
  36. package/dist/string/normalize.cjs +6 -0
  37. package/dist/string/normalize.d.ts +5 -0
  38. package/dist/string/normalize.js +6 -0
  39. package/dist/string/pluralize/index.cjs +6 -0
  40. package/dist/string/pluralize/pluralize.cjs +210 -0
  41. package/dist/string/pluralize/rules/index.cjs +10 -0
  42. package/dist/string/pluralize/rules/irregular.cjs +62 -0
  43. package/dist/string/pluralize/rules/pluralization.cjs +39 -0
  44. package/dist/string/pluralize/rules/singularization.cjs +47 -0
  45. package/dist/string/pluralize/rules/uncountable.cjs +113 -0
  46. package/dist/string/pluralize/types.cjs +1 -0
  47. package/dist/string/slugify/index.cjs +2263 -0
  48. package/dist/string/strip-html-tags.cjs +7 -0
  49. package/dist/string/to-int.cjs +10 -0
  50. package/dist/string/to-sentence-case.cjs +8 -0
  51. package/dist/string/trim.cjs +11 -0
  52. package/dist/string/truncate.cjs +20 -0
  53. package/dist/string/truncate.d.ts +22 -1
  54. package/dist/string/truncate.js +14 -3
  55. package/dist/value/index.cjs +4 -0
  56. package/dist/value/index.d.ts +1 -0
  57. package/dist/value/index.js +4 -0
  58. package/dist/value/is-empty.cjs +14 -0
  59. package/dist/value/is-empty.d.ts +17 -0
  60. package/dist/value/is-empty.js +14 -0
  61. package/package.json +29 -10
  62. package/src/format/index.ts +3 -3
  63. package/src/path/file-url-to-path.ts +12 -0
  64. package/src/path/index.ts +2 -0
  65. package/src/path/normalize.ts +72 -0
  66. package/src/string/normalize.ts +7 -0
  67. package/src/string/truncate.ts +44 -11
  68. package/src/value/index.ts +1 -0
  69. package/src/value/is-empty.ts +31 -0
  70. package/tsconfig.lib.json +36 -35
  71. package/vite.config.ts +75 -77
  72. package/tsconfig.lib.tsbuildinfo +0 -1
@@ -0,0 +1,32 @@
1
+ import { fileURLToPath } from "./file-url-to-path.js";
2
+ const defaultOptions = {
3
+ leadingSlash: "always",
4
+ trailingSlash: "never"
5
+ };
6
+ const windowsPathSepRegExp = /[\\]+/g;
7
+ const unixPathSepRegExp = /[/]+/g;
8
+ const windowsDriveRegExp = /^[a-zA-Z1-9_-]+:\//;
9
+ const fileProtocolRegExp = /^file:\/\//;
10
+ const leadingSlashRegExp = /^\//g;
11
+ const trailingSlashRegExp = /\/$/g;
12
+ function normalize(path, options) {
13
+ const conf = { ...defaultOptions, ...options };
14
+ const sep = "\\";
15
+ let normalPath = path.trim();
16
+ if (fileProtocolRegExp.test(normalPath))
17
+ normalPath = fileURLToPath(normalPath);
18
+ normalPath = normalPath.replace(windowsPathSepRegExp, sep).replace(unixPathSepRegExp, sep);
19
+ if (conf.leadingSlash !== "as-is") {
20
+ normalPath = normalPath.replace(leadingSlashRegExp, "");
21
+ if (conf.leadingSlash === "always" && !windowsDriveRegExp.test(normalPath))
22
+ normalPath = `${sep}${normalPath}`;
23
+ }
24
+ if (conf.trailingSlash !== "as-is") {
25
+ normalPath = normalPath.replace(trailingSlashRegExp, "");
26
+ if (conf.trailingSlash === "always") normalPath = `${normalPath}${sep}`;
27
+ }
28
+ return normalPath;
29
+ }
30
+ export {
31
+ normalize
32
+ };
@@ -0,0 +1,10 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
+ function difference(setA, setB) {
4
+ const _difference = new Set(setA);
5
+ for (const elem of setB) {
6
+ _difference.delete(elem);
7
+ }
8
+ return _difference;
9
+ }
10
+ exports.difference = difference;
@@ -0,0 +1,12 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
+ const set_union = require("./union.cjs");
4
+ const set_intersection = require("./intersection.cjs");
5
+ const set_isSuperset = require("./is-superset.cjs");
6
+ const set_difference = require("./difference.cjs");
7
+ const set_symmetricDifference = require("./symmetric-difference.cjs");
8
+ exports.union = set_union.union;
9
+ exports.intersection = set_intersection.intersection;
10
+ exports.isSuperset = set_isSuperset.isSuperset;
11
+ exports.difference = set_difference.difference;
12
+ exports.symmetricDifference = set_symmetricDifference.symmetricDifference;
@@ -0,0 +1,13 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
+ function intersection(setA, setB) {
4
+ const _setA = setA instanceof Set ? setA : new Set(setA);
5
+ const _intersection = /* @__PURE__ */ new Set();
6
+ for (const elem of setB) {
7
+ if (_setA.has(elem)) {
8
+ _intersection.add(elem);
9
+ }
10
+ }
11
+ return _intersection;
12
+ }
13
+ exports.intersection = intersection;
@@ -0,0 +1,12 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
+ function isSuperset(set, subset) {
4
+ const _set = set instanceof Set ? set : new Set(set);
5
+ for (const elem of subset) {
6
+ if (!_set.has(elem)) {
7
+ return false;
8
+ }
9
+ }
10
+ return true;
11
+ }
12
+ exports.isSuperset = isSuperset;
@@ -0,0 +1,14 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
+ function symmetricDifference(setA, setB) {
4
+ const _difference = new Set(setA);
5
+ for (const elem of setB) {
6
+ if (_difference.has(elem)) {
7
+ _difference.delete(elem);
8
+ } else {
9
+ _difference.add(elem);
10
+ }
11
+ }
12
+ return _difference;
13
+ }
14
+ exports.symmetricDifference = symmetricDifference;
@@ -0,0 +1,10 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
+ function union(setA, setB) {
4
+ const _union = new Set(setA);
5
+ for (const elem of setB) {
6
+ _union.add(elem);
7
+ }
8
+ return _union;
9
+ }
10
+ exports.union = union;
@@ -0,0 +1,4 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
+ const capitalize = (s) => s[0].toUpperCase() + s.slice(1);
4
+ exports.capitalize = capitalize;
@@ -0,0 +1,14 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
+ const string_truncate = require("./truncate.cjs");
4
+ const string_trim = require("./trim.cjs");
5
+ const string_stripHtmlTags = require("./strip-html-tags.cjs");
6
+ const string_capitalize = require("./capitalize.cjs");
7
+ const string_toSentenceCase = require("./to-sentence-case.cjs");
8
+ const string_toInt = require("./to-int.cjs");
9
+ exports.truncate = string_truncate.truncate;
10
+ exports.trim = string_trim.trim;
11
+ exports.stripHtmlTags = string_stripHtmlTags.stripHtmlTags;
12
+ exports.capitalize = string_capitalize.capitalize;
13
+ exports.toSentenceCase = string_toSentenceCase.toSentenceCase;
14
+ exports.stringToInt = string_toInt.stringToInt;
@@ -0,0 +1,6 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
+ function normalize(text) {
4
+ return text.trim().replace(/\s+/g, " ");
5
+ }
6
+ exports.normalize = normalize;
@@ -0,0 +1,5 @@
1
+ /**
2
+ * Trims white spaces and
3
+ * replaces multiple white space characters with a single space
4
+ */
5
+ export declare function normalize(text: string): string;
@@ -0,0 +1,6 @@
1
+ function normalize(text) {
2
+ return text.trim().replace(/\s+/g, " ");
3
+ }
4
+ export {
5
+ normalize
6
+ };
@@ -0,0 +1,6 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
+ const string_pluralize_pluralize = require("./pluralize.cjs");
4
+ const pluralize = new string_pluralize_pluralize.Pluralize();
5
+ exports.Pluralize = string_pluralize_pluralize.Pluralize;
6
+ exports.pluralize = pluralize;
@@ -0,0 +1,210 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
+ const string_pluralize_rules_irregular = require("./rules/irregular.cjs");
4
+ const string_pluralize_rules_pluralization = require("./rules/pluralization.cjs");
5
+ const string_pluralize_rules_singularization = require("./rules/singularization.cjs");
6
+ const string_pluralize_rules_uncountable = require("./rules/uncountable.cjs");
7
+ const TagIndexRegExp = /\$(\d{1,2})/g;
8
+ class Pluralize {
9
+ // Rule storage - pluralize and singularize need to be run sequentially,
10
+ // while other rules can be optimized using an object for instant lookups.
11
+ pluralRules = [];
12
+ singularRules = [];
13
+ uncountables = {};
14
+ irregularPlurals = {};
15
+ irregularSingles = {};
16
+ constructor() {
17
+ for (let index = 0; index < string_pluralize_rules_irregular.IRREGULAR_WORDS.length; index += 1) {
18
+ this.addIrregularRule(
19
+ string_pluralize_rules_irregular.IRREGULAR_WORDS[index][0],
20
+ string_pluralize_rules_irregular.IRREGULAR_WORDS[index][1]
21
+ );
22
+ }
23
+ for (let index = 0; index < string_pluralize_rules_pluralization.PLURALIZATION_RULES.length; index += 1) {
24
+ this.addPluralRule(
25
+ string_pluralize_rules_pluralization.PLURALIZATION_RULES[index][0],
26
+ string_pluralize_rules_pluralization.PLURALIZATION_RULES[index][1]
27
+ );
28
+ }
29
+ for (let index = 0; index < string_pluralize_rules_singularization.SINGULARIZATION_RULES.length; index += 1) {
30
+ this.addSingularRule(
31
+ string_pluralize_rules_singularization.SINGULARIZATION_RULES[index][0],
32
+ string_pluralize_rules_singularization.SINGULARIZATION_RULES[index][1]
33
+ );
34
+ }
35
+ for (let index = 0; index < string_pluralize_rules_uncountable.UNCOUNTABLE_WORDS.length; index += 1) {
36
+ this.addUncountableRule(string_pluralize_rules_uncountable.UNCOUNTABLE_WORDS[index]);
37
+ }
38
+ }
39
+ /**
40
+ * Add a pluralization rule to the collection.
41
+ */
42
+ addPluralRule(rule, replacement) {
43
+ this.pluralRules.push([this.sanitizeRule(rule), replacement]);
44
+ }
45
+ /**
46
+ * Add a singularization rule to the collection.
47
+ */
48
+ addSingularRule(rule, replacement) {
49
+ this.singularRules.push([this.sanitizeRule(rule), replacement]);
50
+ }
51
+ /**
52
+ * Add an uncountable word rule.
53
+ */
54
+ addUncountableRule(word) {
55
+ if (typeof word === "string") {
56
+ this.uncountables[word.toLowerCase()] = true;
57
+ return;
58
+ }
59
+ this.addPluralRule(word, "$0");
60
+ this.addSingularRule(word, "$0");
61
+ }
62
+ /**
63
+ * Add an irregular word definition.
64
+ *
65
+ * @param {string} single
66
+ * @param {string} plural
67
+ */
68
+ addIrregularRule(single, plural) {
69
+ plural = plural.toLowerCase();
70
+ single = single.toLowerCase();
71
+ this.irregularSingles[single] = plural;
72
+ this.irregularPlurals[plural] = single;
73
+ }
74
+ /**
75
+ * Sanitize a pluralization rule to a usable regular expression.
76
+ */
77
+ sanitizeRule(rule) {
78
+ if (typeof rule === "string") {
79
+ return new RegExp(`^${rule}$`, "i");
80
+ }
81
+ return rule;
82
+ }
83
+ /**
84
+ * Pass in a word token to produce a function that can replicate the case on
85
+ * another word.
86
+ */
87
+ restoreCase(word, token) {
88
+ if (word === token) return token;
89
+ if (word === word.toLowerCase()) return token.toLowerCase();
90
+ if (word === word.toUpperCase()) return token.toUpperCase();
91
+ if (word[0] === word[0].toUpperCase()) {
92
+ return token.charAt(0).toUpperCase() + token.substr(1).toLowerCase();
93
+ }
94
+ return token.toLowerCase();
95
+ }
96
+ /**
97
+ * Interpolate a regexp string.
98
+ *
99
+ * @param {string} str
100
+ * @param {Array} args
101
+ * @return {string}
102
+ */
103
+ interpolate(str, args) {
104
+ return str.replace(TagIndexRegExp, (match, index) => {
105
+ return args[index] || "";
106
+ });
107
+ }
108
+ /**
109
+ * Replace a word using a rule.
110
+ */
111
+ replace(word, rule) {
112
+ return word.replace(rule[0], (match, index, ...args) => {
113
+ const result = this.interpolate(rule[1], args);
114
+ if (match === "") {
115
+ return this.restoreCase(word[index - 1], result);
116
+ }
117
+ return this.restoreCase(match, result);
118
+ });
119
+ }
120
+ /**
121
+ * Sanitize a word by passing in the word and sanitization rules.
122
+ */
123
+ sanitizeWord(token, word, rules) {
124
+ if (!token.length || this.uncountables[token]) {
125
+ return word;
126
+ }
127
+ let len = rules.length;
128
+ while (len--) {
129
+ const rule = rules[len];
130
+ if (typeof rule[0] === "string" || rule[0].test(word))
131
+ return this.replace(word, rule);
132
+ }
133
+ return word;
134
+ }
135
+ /**
136
+ * Replace a word with the updated word.
137
+ */
138
+ old_replaceWord(replaceMap, keepMap, rules) {
139
+ return (word) => {
140
+ const token = word.toLowerCase();
141
+ if (keepMap[token]) {
142
+ return this.restoreCase(word, token);
143
+ }
144
+ if (replaceMap[token]) {
145
+ return this.restoreCase(word, replaceMap[token]);
146
+ }
147
+ return this.sanitizeWord(token, word, rules);
148
+ };
149
+ }
150
+ /**
151
+ * Replace a word with the updated word.
152
+ */
153
+ replaceWord(word, direction) {
154
+ const replaceMap = direction === "SingularToPlural" ? this.irregularSingles : this.irregularPlurals;
155
+ const keepMap = direction === "SingularToPlural" ? this.irregularPlurals : this.irregularSingles;
156
+ const rules = direction === "SingularToPlural" ? this.pluralRules : this.singularRules;
157
+ const token = word.toLowerCase();
158
+ if (keepMap[token]) {
159
+ return this.restoreCase(word, token);
160
+ }
161
+ if (replaceMap[token]) {
162
+ return this.restoreCase(word, replaceMap[token]);
163
+ }
164
+ return this.sanitizeWord(token, word, rules);
165
+ }
166
+ /**
167
+ * Check if a word is part of the map.
168
+ */
169
+ checkWord(word, reason) {
170
+ const replaceMap = reason === "Plurality" ? this.irregularSingles : this.irregularPlurals;
171
+ const keepMap = reason === "Plurality" ? this.irregularPlurals : this.irregularSingles;
172
+ const rules = reason === "Singularity" ? this.pluralRules : this.singularRules;
173
+ const token = word.toLowerCase();
174
+ if (keepMap[token]) return true;
175
+ if (replaceMap[token]) return false;
176
+ return this.sanitizeWord(token, token, rules) === token;
177
+ }
178
+ /**
179
+ * Pluralize or singularize a word based on the passed in count.
180
+ */
181
+ pluralize(word, count, inclusive) {
182
+ const pluralized = count === 1 ? this.singular(word) : this.plural(word);
183
+ return (inclusive ? `${count} ` : "") + pluralized;
184
+ }
185
+ /**
186
+ * Pluralize a word.
187
+ */
188
+ plural(singularWord) {
189
+ return this.replaceWord(singularWord, "SingularToPlural");
190
+ }
191
+ /**
192
+ * Check if a word is plural.
193
+ */
194
+ isPlural(word) {
195
+ this.checkWord(word, "Plurality");
196
+ }
197
+ /**
198
+ * Singularize a word.
199
+ */
200
+ singular(pluralWord) {
201
+ return this.replaceWord(pluralWord, "PluralToSingular");
202
+ }
203
+ /**
204
+ * Check if a word is singular.
205
+ */
206
+ isSingular(word) {
207
+ this.checkWord(word, "Singularity");
208
+ }
209
+ }
210
+ exports.Pluralize = Pluralize;
@@ -0,0 +1,10 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
+ const string_pluralize_rules_irregular = require("./irregular.cjs");
4
+ const string_pluralize_rules_pluralization = require("./pluralization.cjs");
5
+ const string_pluralize_rules_singularization = require("./singularization.cjs");
6
+ const string_pluralize_rules_uncountable = require("./uncountable.cjs");
7
+ exports.IRREGULAR_WORDS = string_pluralize_rules_irregular.IRREGULAR_WORDS;
8
+ exports.PLURALIZATION_RULES = string_pluralize_rules_pluralization.PLURALIZATION_RULES;
9
+ exports.SINGULARIZATION_RULES = string_pluralize_rules_singularization.SINGULARIZATION_RULES;
10
+ exports.UNCOUNTABLE_WORDS = string_pluralize_rules_uncountable.UNCOUNTABLE_WORDS;
@@ -0,0 +1,62 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
+ const IRREGULAR_WORDS = [
4
+ // Pronouns.
5
+ ["I", "we"],
6
+ ["me", "us"],
7
+ ["he", "they"],
8
+ ["she", "they"],
9
+ ["them", "them"],
10
+ ["myself", "ourselves"],
11
+ ["yourself", "yourselves"],
12
+ ["itself", "themselves"],
13
+ ["herself", "themselves"],
14
+ ["himself", "themselves"],
15
+ ["themself", "themselves"],
16
+ ["is", "are"],
17
+ ["was", "were"],
18
+ ["has", "have"],
19
+ ["this", "these"],
20
+ ["that", "those"],
21
+ ["my", "our"],
22
+ ["its", "their"],
23
+ ["his", "their"],
24
+ ["her", "their"],
25
+ // Words ending in with a consonant and `o`.
26
+ ["echo", "echoes"],
27
+ ["dingo", "dingoes"],
28
+ ["volcano", "volcanoes"],
29
+ ["tornado", "tornadoes"],
30
+ ["torpedo", "torpedoes"],
31
+ // Ends with `us`.
32
+ ["genus", "genera"],
33
+ ["viscus", "viscera"],
34
+ // Ends with `ma`.
35
+ ["stigma", "stigmata"],
36
+ ["stoma", "stomata"],
37
+ ["dogma", "dogmata"],
38
+ ["lemma", "lemmata"],
39
+ ["schema", "schemata"],
40
+ ["anathema", "anathemata"],
41
+ // Other irregular rules.
42
+ ["ox", "oxen"],
43
+ ["axe", "axes"],
44
+ ["die", "dice"],
45
+ ["yes", "yeses"],
46
+ ["foot", "feet"],
47
+ ["eave", "eaves"],
48
+ ["goose", "geese"],
49
+ ["tooth", "teeth"],
50
+ ["quiz", "quizzes"],
51
+ ["human", "humans"],
52
+ ["proof", "proofs"],
53
+ ["carve", "carves"],
54
+ ["valve", "valves"],
55
+ ["looey", "looies"],
56
+ ["thief", "thieves"],
57
+ ["groove", "grooves"],
58
+ ["pickaxe", "pickaxes"],
59
+ ["passerby", "passersby"],
60
+ ["canvas", "canvases"]
61
+ ];
62
+ exports.IRREGULAR_WORDS = IRREGULAR_WORDS;
@@ -0,0 +1,39 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
+ const PLURALIZATION_RULES = [
4
+ [/s?$/i, "s"],
5
+ [/[^\u0000-\u007F]$/, "$0"],
6
+ [/([^aeiou]ese)$/i, "$1"],
7
+ [/(ax|test)is$/i, "$1es"],
8
+ [/(alias|[^aou]us|t[lm]as|gas|ris)$/i, "$1es"],
9
+ [/(e[mn]u)s?$/i, "$1s"],
10
+ [/([^l]ias|[aeiou]las|[ejzr]as|[iu]am)$/i, "$1"],
11
+ [
12
+ /(alumn|syllab|vir|radi|nucle|fung|cact|stimul|termin|bacill|foc|uter|loc|strat)(?:us|i)$/i,
13
+ "$1i"
14
+ ],
15
+ [/(alumn|alg|vertebr)(?:a|ae)$/i, "$1ae"],
16
+ [/(seraph|cherub)(?:im)?$/i, "$1im"],
17
+ [/(her|at|gr)o$/i, "$1oes"],
18
+ [
19
+ /(agend|addend|millenni|dat|extrem|bacteri|desiderat|strat|candelabr|errat|ov|symposi|curricul|automat|quor)(?:a|um)$/i,
20
+ "$1a"
21
+ ],
22
+ [
23
+ /(apheli|hyperbat|periheli|asyndet|noumen|phenomen|criteri|organ|prolegomen|hedr|automat)(?:a|on)$/i,
24
+ "$1a"
25
+ ],
26
+ [/sis$/i, "ses"],
27
+ [/(?:(kni|wi|li)fe|(ar|l|ea|eo|oa|hoo)f)$/i, "$1$2ves"],
28
+ [/([^aeiouy]|qu)y$/i, "$1ies"],
29
+ [/([^ch][ieo][ln])ey$/i, "$1ies"],
30
+ [/(x|ch|ss|sh|zz)$/i, "$1es"],
31
+ [/(matr|cod|mur|sil|vert|ind|append)(?:ix|ex)$/i, "$1ices"],
32
+ [/\b((?:tit)?m|l)(?:ice|ouse)$/i, "$1ice"],
33
+ [/(pe)(?:rson|ople)$/i, "$1ople"],
34
+ [/(child)(?:ren)?$/i, "$1ren"],
35
+ [/eaux$/i, "$0"],
36
+ [/m[ae]n$/i, "men"],
37
+ ["thou", "you"]
38
+ ];
39
+ exports.PLURALIZATION_RULES = PLURALIZATION_RULES;
@@ -0,0 +1,47 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
+ const SINGULARIZATION_RULES = [
4
+ [/s$/i, ""],
5
+ [/(ss)$/i, "$1"],
6
+ [/(wi|kni|(?:after|half|high|low|mid|non|night|\W|^)li)ves$/i, "$1fe"],
7
+ [/(ar|(?:wo|[ae])l|[eo][ao])ves$/i, "$1f"],
8
+ [/ies$/i, "y"],
9
+ [/(dg|ss|ois|lk|ok|wn|mb|th|ch|ec|oal|is|ck|ix|sser|ts|wb)ies$/i, "$1ie"],
10
+ [
11
+ /\b(l|(?:neck|cross|hog|aun)?t|coll|faer|food|gen|goon|group|hipp|junk|vegg|(?:pork)?p|charl|calor|cut)ies$/i,
12
+ "$1ie"
13
+ ],
14
+ [/\b(mon|smil)ies$/i, "$1ey"],
15
+ [/\b((?:tit)?m|l)ice$/i, "$1ouse"],
16
+ [/(seraph|cherub)im$/i, "$1"],
17
+ [
18
+ /(x|ch|ss|sh|zz|tto|go|cho|alias|[^aou]us|t[lm]as|gas|(?:her|at|gr)o|[aeiou]ris)(?:es)?$/i,
19
+ "$1"
20
+ ],
21
+ [
22
+ /(analy|diagno|parenthe|progno|synop|the|empha|cri|ne)(?:sis|ses)$/i,
23
+ "$1sis"
24
+ ],
25
+ [/(movie|twelve|abuse|e[mn]u)s$/i, "$1"],
26
+ [/(test)(?:is|es)$/i, "$1is"],
27
+ [
28
+ /(alumn|syllab|vir|radi|nucle|fung|cact|stimul|termin|bacill|foc|uter|loc|strat)(?:us|i)$/i,
29
+ "$1us"
30
+ ],
31
+ [
32
+ /(agend|addend|millenni|dat|extrem|bacteri|desiderat|strat|candelabr|errat|ov|symposi|curricul|quor)a$/i,
33
+ "$1um"
34
+ ],
35
+ [
36
+ /(apheli|hyperbat|periheli|asyndet|noumen|phenomen|criteri|organ|prolegomen|hedr|automat)a$/i,
37
+ "$1on"
38
+ ],
39
+ [/(alumn|alg|vertebr)ae$/i, "$1a"],
40
+ [/(cod|mur|sil|vert|ind)ices$/i, "$1ex"],
41
+ [/(matr|append)ices$/i, "$1ix"],
42
+ [/(pe)(rson|ople)$/i, "$1rson"],
43
+ [/(child)ren$/i, "$1"],
44
+ [/(eau)x?$/i, "$1"],
45
+ [/men$/i, "man"]
46
+ ];
47
+ exports.SINGULARIZATION_RULES = SINGULARIZATION_RULES;
@@ -0,0 +1,113 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
+ const UNCOUNTABLE_WORDS = [
4
+ // Singular words with no plurals.
5
+ "adulthood",
6
+ "advice",
7
+ "agenda",
8
+ "aid",
9
+ "aircraft",
10
+ "alcohol",
11
+ "ammo",
12
+ "analytics",
13
+ "anime",
14
+ "athletics",
15
+ "audio",
16
+ "bison",
17
+ "blood",
18
+ "bream",
19
+ "buffalo",
20
+ "butter",
21
+ "carp",
22
+ "cash",
23
+ "chassis",
24
+ "chess",
25
+ "clothing",
26
+ "cod",
27
+ "commerce",
28
+ "cooperation",
29
+ "corps",
30
+ "debris",
31
+ "diabetes",
32
+ "digestion",
33
+ "elk",
34
+ "energy",
35
+ "equipment",
36
+ "excretion",
37
+ "expertise",
38
+ "firmware",
39
+ "flounder",
40
+ "fun",
41
+ "gallows",
42
+ "garbage",
43
+ "graffiti",
44
+ "hardware",
45
+ "headquarters",
46
+ "health",
47
+ "herpes",
48
+ "highjinks",
49
+ "homework",
50
+ "housework",
51
+ "information",
52
+ "jeans",
53
+ "justice",
54
+ "kudos",
55
+ "labour",
56
+ "literature",
57
+ "machinery",
58
+ "mackerel",
59
+ "mail",
60
+ "media",
61
+ "mews",
62
+ "moose",
63
+ "music",
64
+ "mud",
65
+ "manga",
66
+ "news",
67
+ "only",
68
+ "personnel",
69
+ "pike",
70
+ "plankton",
71
+ "pliers",
72
+ "police",
73
+ "pollution",
74
+ "premises",
75
+ "rain",
76
+ "research",
77
+ "rice",
78
+ "salmon",
79
+ "scissors",
80
+ "series",
81
+ "sewage",
82
+ "shambles",
83
+ "shrimp",
84
+ "software",
85
+ "staff",
86
+ "swine",
87
+ "tennis",
88
+ "traffic",
89
+ "transportation",
90
+ "trout",
91
+ "tuna",
92
+ "wealth",
93
+ "welfare",
94
+ "whiting",
95
+ "wildebeest",
96
+ "wildlife",
97
+ "you",
98
+ /pok[eé]mon$/i,
99
+ // Regexes.
100
+ /[^aeiou]ese$/i,
101
+ // "chinese", "japanese"
102
+ /deer$/i,
103
+ // "deer", "reindeer"
104
+ /fish$/i,
105
+ // "fish", "blowfish", "angelfish"
106
+ /measles$/i,
107
+ /o[iu]s$/i,
108
+ // "carnivorous"
109
+ /pox$/i,
110
+ // "chickpox", "smallpox"
111
+ /sheep$/i
112
+ ];
113
+ exports.UNCOUNTABLE_WORDS = UNCOUNTABLE_WORDS;
@@ -0,0 +1 @@
1
+ "use strict";