@art-suite/art-core-ts-string-lib 0.1.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/README.md ADDED
@@ -0,0 +1,62 @@
1
+ # @art-suite/art-core-ts-string-lib
2
+
3
+ Essential string utilities for TypeScript, including number formatting and robust pluralization.
4
+
5
+ ## Why This Module?
6
+
7
+ String manipulation is a core part of any application, but common tasks like formatting numbers with commas or pluralizing words are often re-implemented or handled inconsistently. This module provides focused, type-safe helpers for these needs, with a simple, ergonomic API.
8
+
9
+ - **Commaize:** Format numbers or numeric strings with thousands separators.
10
+ - **Pluralize:** Intelligently pluralize words based on count, with support for custom plural forms and edge cases. Built on top of the popular [`pluralize`](https://www.npmjs.com/package/pluralize) npm package, but presented in a more convenient, TypeScript-friendly API.
11
+
12
+ ## Example Installation and Use (Required)
13
+
14
+ Install with npm:
15
+
16
+ ```sh
17
+ npm install @art-suite/art-core-ts-string-lib
18
+ ```
19
+
20
+ Basic usage:
21
+
22
+ ```ts
23
+ import { commaize, pluralize } from "@art-suite/art-core-ts-string-lib";
24
+
25
+ // Format numbers with commas
26
+ commaize(1234567); // "1,234,567"
27
+ commaize("987654321"); // "987,654,321"
28
+
29
+ // Pluralize words based on count
30
+ pluralize("cat"); // "cats"
31
+ pluralize("cat", 1); // "1 cat"
32
+ pluralize("cat", 2); // "2 cats"
33
+ pluralize(3, "child", "children"); // "3 children"
34
+ pluralize("person", 2); // "2 people"
35
+ ```
36
+
37
+ ## Functional Overview
38
+
39
+ ### `commaize(x: number | string): string`
40
+
41
+ Adds commas as thousands separators to a number or numeric string.
42
+
43
+ - `commaize(1234567)` → `"1,234,567"`
44
+ - `commaize("1000000")` → `"1,000,000"`
45
+
46
+ ### `pluralize(...)`
47
+
48
+ Pluralizes a word based on count, with flexible call signatures:
49
+
50
+ - `pluralize(singleForm: string)` — Returns the plural form: `pluralize("cat")` → `"cats"`
51
+ - `pluralize(singleForm: string, count: number)` — Returns `"count word(s)"`: `pluralize("cat", 2)` → `"2 cats"`
52
+ - `pluralize(count: number, singleForm: string)` — Same as above: `pluralize(1, "dog")` → `"1 dog"`
53
+ - `pluralize(singleForm: string, count: number, pluralForm: string)` — Custom plural: `pluralize("child", 2, "children")` → `"2 children"`
54
+ - `pluralize(count: number, singleForm: string, pluralForm: string)` — Same as above.
55
+
56
+ Handles edge cases and preserves punctuation (e.g., `"bus!"` → `"buses!"`).
57
+
58
+ > **Note:** This utility leverages the [`pluralize`](https://www.npmjs.com/package/pluralize) npm package under the hood, but wraps it in a more convenient, TypeScript-friendly API and handles additional edge cases. In particular, the `pluralize(number, noun)` signature is closer to normal English and more ergonomic than the default npm pluralize API.
59
+
60
+ ## API Documentation Reference
61
+
62
+ For detailed information on all exported functions and their parameters, please refer to the TypeScript typings and JSDoc comments within the source code.
package/dist/index.cjs ADDED
@@ -0,0 +1,463 @@
1
+ "use strict";
2
+ var __create = Object.create;
3
+ var __defProp = Object.defineProperty;
4
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
+ var __getOwnPropNames = Object.getOwnPropertyNames;
6
+ var __getProtoOf = Object.getPrototypeOf;
7
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
8
+ var __commonJS = (cb, mod) => function __require() {
9
+ return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
10
+ };
11
+ var __export = (target, all) => {
12
+ for (var name in all)
13
+ __defProp(target, name, { get: all[name], enumerable: true });
14
+ };
15
+ var __copyProps = (to, from, except, desc) => {
16
+ if (from && typeof from === "object" || typeof from === "function") {
17
+ for (let key of __getOwnPropNames(from))
18
+ if (!__hasOwnProp.call(to, key) && key !== except)
19
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
20
+ }
21
+ return to;
22
+ };
23
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
24
+ // If the importer is in node compatibility mode or this is not an ESM
25
+ // file that has been converted to a CommonJS file using a Babel-
26
+ // compatible transform (i.e. "__esModule" has not been set), then set
27
+ // "default" to the CommonJS "module.exports" for node compatibility.
28
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
29
+ mod
30
+ ));
31
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
32
+
33
+ // ../../node_modules/pluralize/pluralize.js
34
+ var require_pluralize = __commonJS({
35
+ "../../node_modules/pluralize/pluralize.js"(exports2, module2) {
36
+ "use strict";
37
+ (function(root, pluralize2) {
38
+ if (typeof require === "function" && typeof exports2 === "object" && typeof module2 === "object") {
39
+ module2.exports = pluralize2();
40
+ } else if (typeof define === "function" && define.amd) {
41
+ define(function() {
42
+ return pluralize2();
43
+ });
44
+ } else {
45
+ root.pluralize = pluralize2();
46
+ }
47
+ })(exports2, function() {
48
+ var pluralRules = [];
49
+ var singularRules = [];
50
+ var uncountables = {};
51
+ var irregularPlurals = {};
52
+ var irregularSingles = {};
53
+ function sanitizeRule(rule) {
54
+ if (typeof rule === "string") {
55
+ return new RegExp("^" + rule + "$", "i");
56
+ }
57
+ return rule;
58
+ }
59
+ function restoreCase(word, token) {
60
+ if (word === token) return token;
61
+ if (word === word.toLowerCase()) return token.toLowerCase();
62
+ if (word === word.toUpperCase()) return token.toUpperCase();
63
+ if (word[0] === word[0].toUpperCase()) {
64
+ return token.charAt(0).toUpperCase() + token.substr(1).toLowerCase();
65
+ }
66
+ return token.toLowerCase();
67
+ }
68
+ function interpolate(str, args) {
69
+ return str.replace(/\$(\d{1,2})/g, function(match, index) {
70
+ return args[index] || "";
71
+ });
72
+ }
73
+ function replace(word, rule) {
74
+ return word.replace(rule[0], function(match, index) {
75
+ var result = interpolate(rule[1], arguments);
76
+ if (match === "") {
77
+ return restoreCase(word[index - 1], result);
78
+ }
79
+ return restoreCase(match, result);
80
+ });
81
+ }
82
+ function sanitizeWord(token, word, rules) {
83
+ if (!token.length || uncountables.hasOwnProperty(token)) {
84
+ return word;
85
+ }
86
+ var len = rules.length;
87
+ while (len--) {
88
+ var rule = rules[len];
89
+ if (rule[0].test(word)) return replace(word, rule);
90
+ }
91
+ return word;
92
+ }
93
+ function replaceWord(replaceMap, keepMap, rules) {
94
+ return function(word) {
95
+ var token = word.toLowerCase();
96
+ if (keepMap.hasOwnProperty(token)) {
97
+ return restoreCase(word, token);
98
+ }
99
+ if (replaceMap.hasOwnProperty(token)) {
100
+ return restoreCase(word, replaceMap[token]);
101
+ }
102
+ return sanitizeWord(token, word, rules);
103
+ };
104
+ }
105
+ function checkWord(replaceMap, keepMap, rules, bool) {
106
+ return function(word) {
107
+ var token = word.toLowerCase();
108
+ if (keepMap.hasOwnProperty(token)) return true;
109
+ if (replaceMap.hasOwnProperty(token)) return false;
110
+ return sanitizeWord(token, token, rules) === token;
111
+ };
112
+ }
113
+ function pluralize2(word, count, inclusive) {
114
+ var pluralized = count === 1 ? pluralize2.singular(word) : pluralize2.plural(word);
115
+ return (inclusive ? count + " " : "") + pluralized;
116
+ }
117
+ pluralize2.plural = replaceWord(
118
+ irregularSingles,
119
+ irregularPlurals,
120
+ pluralRules
121
+ );
122
+ pluralize2.isPlural = checkWord(
123
+ irregularSingles,
124
+ irregularPlurals,
125
+ pluralRules
126
+ );
127
+ pluralize2.singular = replaceWord(
128
+ irregularPlurals,
129
+ irregularSingles,
130
+ singularRules
131
+ );
132
+ pluralize2.isSingular = checkWord(
133
+ irregularPlurals,
134
+ irregularSingles,
135
+ singularRules
136
+ );
137
+ pluralize2.addPluralRule = function(rule, replacement) {
138
+ pluralRules.push([sanitizeRule(rule), replacement]);
139
+ };
140
+ pluralize2.addSingularRule = function(rule, replacement) {
141
+ singularRules.push([sanitizeRule(rule), replacement]);
142
+ };
143
+ pluralize2.addUncountableRule = function(word) {
144
+ if (typeof word === "string") {
145
+ uncountables[word.toLowerCase()] = true;
146
+ return;
147
+ }
148
+ pluralize2.addPluralRule(word, "$0");
149
+ pluralize2.addSingularRule(word, "$0");
150
+ };
151
+ pluralize2.addIrregularRule = function(single, plural2) {
152
+ plural2 = plural2.toLowerCase();
153
+ single = single.toLowerCase();
154
+ irregularSingles[single] = plural2;
155
+ irregularPlurals[plural2] = single;
156
+ };
157
+ [
158
+ // Pronouns.
159
+ ["I", "we"],
160
+ ["me", "us"],
161
+ ["he", "they"],
162
+ ["she", "they"],
163
+ ["them", "them"],
164
+ ["myself", "ourselves"],
165
+ ["yourself", "yourselves"],
166
+ ["itself", "themselves"],
167
+ ["herself", "themselves"],
168
+ ["himself", "themselves"],
169
+ ["themself", "themselves"],
170
+ ["is", "are"],
171
+ ["was", "were"],
172
+ ["has", "have"],
173
+ ["this", "these"],
174
+ ["that", "those"],
175
+ // Words ending in with a consonant and `o`.
176
+ ["echo", "echoes"],
177
+ ["dingo", "dingoes"],
178
+ ["volcano", "volcanoes"],
179
+ ["tornado", "tornadoes"],
180
+ ["torpedo", "torpedoes"],
181
+ // Ends with `us`.
182
+ ["genus", "genera"],
183
+ ["viscus", "viscera"],
184
+ // Ends with `ma`.
185
+ ["stigma", "stigmata"],
186
+ ["stoma", "stomata"],
187
+ ["dogma", "dogmata"],
188
+ ["lemma", "lemmata"],
189
+ ["schema", "schemata"],
190
+ ["anathema", "anathemata"],
191
+ // Other irregular rules.
192
+ ["ox", "oxen"],
193
+ ["axe", "axes"],
194
+ ["die", "dice"],
195
+ ["yes", "yeses"],
196
+ ["foot", "feet"],
197
+ ["eave", "eaves"],
198
+ ["goose", "geese"],
199
+ ["tooth", "teeth"],
200
+ ["quiz", "quizzes"],
201
+ ["human", "humans"],
202
+ ["proof", "proofs"],
203
+ ["carve", "carves"],
204
+ ["valve", "valves"],
205
+ ["looey", "looies"],
206
+ ["thief", "thieves"],
207
+ ["groove", "grooves"],
208
+ ["pickaxe", "pickaxes"],
209
+ ["passerby", "passersby"]
210
+ ].forEach(function(rule) {
211
+ return pluralize2.addIrregularRule(rule[0], rule[1]);
212
+ });
213
+ [
214
+ [/s?$/i, "s"],
215
+ [/[^\u0000-\u007F]$/i, "$0"],
216
+ [/([^aeiou]ese)$/i, "$1"],
217
+ [/(ax|test)is$/i, "$1es"],
218
+ [/(alias|[^aou]us|t[lm]as|gas|ris)$/i, "$1es"],
219
+ [/(e[mn]u)s?$/i, "$1s"],
220
+ [/([^l]ias|[aeiou]las|[ejzr]as|[iu]am)$/i, "$1"],
221
+ [/(alumn|syllab|vir|radi|nucle|fung|cact|stimul|termin|bacill|foc|uter|loc|strat)(?:us|i)$/i, "$1i"],
222
+ [/(alumn|alg|vertebr)(?:a|ae)$/i, "$1ae"],
223
+ [/(seraph|cherub)(?:im)?$/i, "$1im"],
224
+ [/(her|at|gr)o$/i, "$1oes"],
225
+ [/(agend|addend|millenni|dat|extrem|bacteri|desiderat|strat|candelabr|errat|ov|symposi|curricul|automat|quor)(?:a|um)$/i, "$1a"],
226
+ [/(apheli|hyperbat|periheli|asyndet|noumen|phenomen|criteri|organ|prolegomen|hedr|automat)(?:a|on)$/i, "$1a"],
227
+ [/sis$/i, "ses"],
228
+ [/(?:(kni|wi|li)fe|(ar|l|ea|eo|oa|hoo)f)$/i, "$1$2ves"],
229
+ [/([^aeiouy]|qu)y$/i, "$1ies"],
230
+ [/([^ch][ieo][ln])ey$/i, "$1ies"],
231
+ [/(x|ch|ss|sh|zz)$/i, "$1es"],
232
+ [/(matr|cod|mur|sil|vert|ind|append)(?:ix|ex)$/i, "$1ices"],
233
+ [/\b((?:tit)?m|l)(?:ice|ouse)$/i, "$1ice"],
234
+ [/(pe)(?:rson|ople)$/i, "$1ople"],
235
+ [/(child)(?:ren)?$/i, "$1ren"],
236
+ [/eaux$/i, "$0"],
237
+ [/m[ae]n$/i, "men"],
238
+ ["thou", "you"]
239
+ ].forEach(function(rule) {
240
+ return pluralize2.addPluralRule(rule[0], rule[1]);
241
+ });
242
+ [
243
+ [/s$/i, ""],
244
+ [/(ss)$/i, "$1"],
245
+ [/(wi|kni|(?:after|half|high|low|mid|non|night|[^\w]|^)li)ves$/i, "$1fe"],
246
+ [/(ar|(?:wo|[ae])l|[eo][ao])ves$/i, "$1f"],
247
+ [/ies$/i, "y"],
248
+ [/\b([pl]|zomb|(?:neck|cross)?t|coll|faer|food|gen|goon|group|lass|talk|goal|cut)ies$/i, "$1ie"],
249
+ [/\b(mon|smil)ies$/i, "$1ey"],
250
+ [/\b((?:tit)?m|l)ice$/i, "$1ouse"],
251
+ [/(seraph|cherub)im$/i, "$1"],
252
+ [/(x|ch|ss|sh|zz|tto|go|cho|alias|[^aou]us|t[lm]as|gas|(?:her|at|gr)o|[aeiou]ris)(?:es)?$/i, "$1"],
253
+ [/(analy|diagno|parenthe|progno|synop|the|empha|cri|ne)(?:sis|ses)$/i, "$1sis"],
254
+ [/(movie|twelve|abuse|e[mn]u)s$/i, "$1"],
255
+ [/(test)(?:is|es)$/i, "$1is"],
256
+ [/(alumn|syllab|vir|radi|nucle|fung|cact|stimul|termin|bacill|foc|uter|loc|strat)(?:us|i)$/i, "$1us"],
257
+ [/(agend|addend|millenni|dat|extrem|bacteri|desiderat|strat|candelabr|errat|ov|symposi|curricul|quor)a$/i, "$1um"],
258
+ [/(apheli|hyperbat|periheli|asyndet|noumen|phenomen|criteri|organ|prolegomen|hedr|automat)a$/i, "$1on"],
259
+ [/(alumn|alg|vertebr)ae$/i, "$1a"],
260
+ [/(cod|mur|sil|vert|ind)ices$/i, "$1ex"],
261
+ [/(matr|append)ices$/i, "$1ix"],
262
+ [/(pe)(rson|ople)$/i, "$1rson"],
263
+ [/(child)ren$/i, "$1"],
264
+ [/(eau)x?$/i, "$1"],
265
+ [/men$/i, "man"]
266
+ ].forEach(function(rule) {
267
+ return pluralize2.addSingularRule(rule[0], rule[1]);
268
+ });
269
+ [
270
+ // Singular words with no plurals.
271
+ "adulthood",
272
+ "advice",
273
+ "agenda",
274
+ "aid",
275
+ "aircraft",
276
+ "alcohol",
277
+ "ammo",
278
+ "analytics",
279
+ "anime",
280
+ "athletics",
281
+ "audio",
282
+ "bison",
283
+ "blood",
284
+ "bream",
285
+ "buffalo",
286
+ "butter",
287
+ "carp",
288
+ "cash",
289
+ "chassis",
290
+ "chess",
291
+ "clothing",
292
+ "cod",
293
+ "commerce",
294
+ "cooperation",
295
+ "corps",
296
+ "debris",
297
+ "diabetes",
298
+ "digestion",
299
+ "elk",
300
+ "energy",
301
+ "equipment",
302
+ "excretion",
303
+ "expertise",
304
+ "firmware",
305
+ "flounder",
306
+ "fun",
307
+ "gallows",
308
+ "garbage",
309
+ "graffiti",
310
+ "hardware",
311
+ "headquarters",
312
+ "health",
313
+ "herpes",
314
+ "highjinks",
315
+ "homework",
316
+ "housework",
317
+ "information",
318
+ "jeans",
319
+ "justice",
320
+ "kudos",
321
+ "labour",
322
+ "literature",
323
+ "machinery",
324
+ "mackerel",
325
+ "mail",
326
+ "media",
327
+ "mews",
328
+ "moose",
329
+ "music",
330
+ "mud",
331
+ "manga",
332
+ "news",
333
+ "only",
334
+ "personnel",
335
+ "pike",
336
+ "plankton",
337
+ "pliers",
338
+ "police",
339
+ "pollution",
340
+ "premises",
341
+ "rain",
342
+ "research",
343
+ "rice",
344
+ "salmon",
345
+ "scissors",
346
+ "series",
347
+ "sewage",
348
+ "shambles",
349
+ "shrimp",
350
+ "software",
351
+ "species",
352
+ "staff",
353
+ "swine",
354
+ "tennis",
355
+ "traffic",
356
+ "transportation",
357
+ "trout",
358
+ "tuna",
359
+ "wealth",
360
+ "welfare",
361
+ "whiting",
362
+ "wildebeest",
363
+ "wildlife",
364
+ "you",
365
+ /pok[eé]mon$/i,
366
+ // Regexes.
367
+ /[^aeiou]ese$/i,
368
+ // "chinese", "japanese"
369
+ /deer$/i,
370
+ // "deer", "reindeer"
371
+ /fish$/i,
372
+ // "fish", "blowfish", "angelfish"
373
+ /measles$/i,
374
+ /o[iu]s$/i,
375
+ // "carnivorous"
376
+ /pox$/i,
377
+ // "chickpox", "smallpox"
378
+ /sheep$/i
379
+ ].forEach(pluralize2.addUncountableRule);
380
+ return pluralize2;
381
+ });
382
+ }
383
+ });
384
+
385
+ // src/index.ts
386
+ var index_exports = {};
387
+ __export(index_exports, {
388
+ addIrregularRule: () => addIrregularRule,
389
+ addPluralRule: () => addPluralRule,
390
+ addSingularRule: () => addSingularRule,
391
+ addUncountableRule: () => addUncountableRule,
392
+ commaize: () => commaize,
393
+ isPlural: () => isPlural,
394
+ isSingular: () => isSingular,
395
+ plural: () => plural,
396
+ pluralize: () => pluralize,
397
+ singular: () => singular
398
+ });
399
+ module.exports = __toCommonJS(index_exports);
400
+
401
+ // src/commaize.ts
402
+ var commaize = (x) => x.toString().replace(/\B(?=(\d{3})+(?!\d))/g, ",");
403
+
404
+ // src/pluralize.ts
405
+ var import_pluralize = __toESM(require_pluralize(), 1);
406
+ var import_art_core_ts_types = require("@art-suite/art-core-ts-types");
407
+ var patchedNpmPluralize = (noun, count, inclusive) => {
408
+ const match = /^(.*?)([_\W]+)$/.exec(noun);
409
+ if (match) {
410
+ const [__, mainNoun, append] = match;
411
+ const out = (0, import_pluralize.default)(mainNoun, count, inclusive);
412
+ return out + append;
413
+ }
414
+ return (0, import_pluralize.default)(noun, count, inclusive);
415
+ };
416
+ var {
417
+ plural,
418
+ singular,
419
+ isSingular,
420
+ isPlural,
421
+ addPluralRule,
422
+ addSingularRule,
423
+ addIrregularRule,
424
+ addUncountableRule
425
+ } = import_pluralize.default;
426
+ var pluralize = (a, b, pluralForm) => {
427
+ let singleForm;
428
+ let number = null;
429
+ if ((0, import_art_core_ts_types.isNumber)(b)) {
430
+ if (!(0, import_art_core_ts_types.isString)(a)) {
431
+ throw new Error(`singleForm and pluralForm(optional) should be non-empty strings (inputs: ${JSON.stringify({ a, b, pluralForm })}`);
432
+ }
433
+ singleForm = a;
434
+ number = b;
435
+ } else if ((0, import_art_core_ts_types.isNumber)(a)) {
436
+ if (!(0, import_art_core_ts_types.isString)(b)) {
437
+ throw new Error(`singleForm and pluralForm(optional) should be non-empty strings (inputs: ${JSON.stringify({ a, b, pluralForm })}`);
438
+ }
439
+ singleForm = b;
440
+ number = a;
441
+ } else {
442
+ if (!(0, import_art_core_ts_types.isString)(a)) throw new Error(`singleForm and pluralForm(optional) should be non-empty strings (inputs: ${JSON.stringify({ a, b, pluralForm })}`);
443
+ singleForm = a;
444
+ number = null;
445
+ }
446
+ if (pluralForm) return `${number} ${number == 1 ? singleForm : pluralForm}`;
447
+ if (number != null) return patchedNpmPluralize(singleForm, number, true);
448
+ return patchedNpmPluralize(singleForm);
449
+ };
450
+ // Annotate the CommonJS export names for ESM import in node:
451
+ 0 && (module.exports = {
452
+ addIrregularRule,
453
+ addPluralRule,
454
+ addSingularRule,
455
+ addUncountableRule,
456
+ commaize,
457
+ isPlural,
458
+ isSingular,
459
+ plural,
460
+ pluralize,
461
+ singular
462
+ });
463
+ //# sourceMappingURL=index.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../node_modules/pluralize/pluralize.js","../src/index.ts","../src/commaize.ts","../src/pluralize.ts"],"sourcesContent":["/* global define */\n\n(function (root, pluralize) {\n /* istanbul ignore else */\n if (typeof require === 'function' && typeof exports === 'object' && typeof module === 'object') {\n // Node.\n module.exports = pluralize();\n } else if (typeof define === 'function' && define.amd) {\n // AMD, registers as an anonymous module.\n define(function () {\n return pluralize();\n });\n } else {\n // Browser global.\n root.pluralize = pluralize();\n }\n})(this, function () {\n // Rule storage - pluralize and singularize need to be run sequentially,\n // while other rules can be optimized using an object for instant lookups.\n var pluralRules = [];\n var singularRules = [];\n var uncountables = {};\n var irregularPlurals = {};\n var irregularSingles = {};\n\n /**\n * Sanitize a pluralization rule to a usable regular expression.\n *\n * @param {(RegExp|string)} rule\n * @return {RegExp}\n */\n function sanitizeRule (rule) {\n if (typeof rule === 'string') {\n return new RegExp('^' + rule + '$', 'i');\n }\n\n return rule;\n }\n\n /**\n * Pass in a word token to produce a function that can replicate the case on\n * another word.\n *\n * @param {string} word\n * @param {string} token\n * @return {Function}\n */\n function restoreCase (word, token) {\n // Tokens are an exact match.\n if (word === token) return token;\n\n // Lower cased words. E.g. \"hello\".\n if (word === word.toLowerCase()) return token.toLowerCase();\n\n // Upper cased words. E.g. \"WHISKY\".\n if (word === word.toUpperCase()) return token.toUpperCase();\n\n // Title cased words. E.g. \"Title\".\n if (word[0] === word[0].toUpperCase()) {\n return token.charAt(0).toUpperCase() + token.substr(1).toLowerCase();\n }\n\n // Lower cased words. E.g. \"test\".\n return token.toLowerCase();\n }\n\n /**\n * Interpolate a regexp string.\n *\n * @param {string} str\n * @param {Array} args\n * @return {string}\n */\n function interpolate (str, args) {\n return str.replace(/\\$(\\d{1,2})/g, function (match, index) {\n return args[index] || '';\n });\n }\n\n /**\n * Replace a word using a rule.\n *\n * @param {string} word\n * @param {Array} rule\n * @return {string}\n */\n function replace (word, rule) {\n return word.replace(rule[0], function (match, index) {\n var result = interpolate(rule[1], arguments);\n\n if (match === '') {\n return restoreCase(word[index - 1], result);\n }\n\n return restoreCase(match, result);\n });\n }\n\n /**\n * Sanitize a word by passing in the word and sanitization rules.\n *\n * @param {string} token\n * @param {string} word\n * @param {Array} rules\n * @return {string}\n */\n function sanitizeWord (token, word, rules) {\n // Empty string or doesn't need fixing.\n if (!token.length || uncountables.hasOwnProperty(token)) {\n return word;\n }\n\n var len = rules.length;\n\n // Iterate over the sanitization rules and use the first one to match.\n while (len--) {\n var rule = rules[len];\n\n if (rule[0].test(word)) return replace(word, rule);\n }\n\n return word;\n }\n\n /**\n * Replace a word with the updated word.\n *\n * @param {Object} replaceMap\n * @param {Object} keepMap\n * @param {Array} rules\n * @return {Function}\n */\n function replaceWord (replaceMap, keepMap, rules) {\n return function (word) {\n // Get the correct token and case restoration functions.\n var token = word.toLowerCase();\n\n // Check against the keep object map.\n if (keepMap.hasOwnProperty(token)) {\n return restoreCase(word, token);\n }\n\n // Check against the replacement map for a direct word replacement.\n if (replaceMap.hasOwnProperty(token)) {\n return restoreCase(word, replaceMap[token]);\n }\n\n // Run all the rules against the word.\n return sanitizeWord(token, word, rules);\n };\n }\n\n /**\n * Check if a word is part of the map.\n */\n function checkWord (replaceMap, keepMap, rules, bool) {\n return function (word) {\n var token = word.toLowerCase();\n\n if (keepMap.hasOwnProperty(token)) return true;\n if (replaceMap.hasOwnProperty(token)) return false;\n\n return sanitizeWord(token, token, rules) === token;\n };\n }\n\n /**\n * Pluralize or singularize a word based on the passed in count.\n *\n * @param {string} word The word to pluralize\n * @param {number} count How many of the word exist\n * @param {boolean} inclusive Whether to prefix with the number (e.g. 3 ducks)\n * @return {string}\n */\n function pluralize (word, count, inclusive) {\n var pluralized = count === 1\n ? pluralize.singular(word) : pluralize.plural(word);\n\n return (inclusive ? count + ' ' : '') + pluralized;\n }\n\n /**\n * Pluralize a word.\n *\n * @type {Function}\n */\n pluralize.plural = replaceWord(\n irregularSingles, irregularPlurals, pluralRules\n );\n\n /**\n * Check if a word is plural.\n *\n * @type {Function}\n */\n pluralize.isPlural = checkWord(\n irregularSingles, irregularPlurals, pluralRules\n );\n\n /**\n * Singularize a word.\n *\n * @type {Function}\n */\n pluralize.singular = replaceWord(\n irregularPlurals, irregularSingles, singularRules\n );\n\n /**\n * Check if a word is singular.\n *\n * @type {Function}\n */\n pluralize.isSingular = checkWord(\n irregularPlurals, irregularSingles, singularRules\n );\n\n /**\n * Add a pluralization rule to the collection.\n *\n * @param {(string|RegExp)} rule\n * @param {string} replacement\n */\n pluralize.addPluralRule = function (rule, replacement) {\n pluralRules.push([sanitizeRule(rule), replacement]);\n };\n\n /**\n * Add a singularization rule to the collection.\n *\n * @param {(string|RegExp)} rule\n * @param {string} replacement\n */\n pluralize.addSingularRule = function (rule, replacement) {\n singularRules.push([sanitizeRule(rule), replacement]);\n };\n\n /**\n * Add an uncountable word rule.\n *\n * @param {(string|RegExp)} word\n */\n pluralize.addUncountableRule = function (word) {\n if (typeof word === 'string') {\n uncountables[word.toLowerCase()] = true;\n return;\n }\n\n // Set singular and plural references for the word.\n pluralize.addPluralRule(word, '$0');\n pluralize.addSingularRule(word, '$0');\n };\n\n /**\n * Add an irregular word definition.\n *\n * @param {string} single\n * @param {string} plural\n */\n pluralize.addIrregularRule = function (single, plural) {\n plural = plural.toLowerCase();\n single = single.toLowerCase();\n\n irregularSingles[single] = plural;\n irregularPlurals[plural] = single;\n };\n\n /**\n * Irregular rules.\n */\n [\n // Pronouns.\n ['I', 'we'],\n ['me', 'us'],\n ['he', 'they'],\n ['she', 'they'],\n ['them', 'them'],\n ['myself', 'ourselves'],\n ['yourself', 'yourselves'],\n ['itself', 'themselves'],\n ['herself', 'themselves'],\n ['himself', 'themselves'],\n ['themself', 'themselves'],\n ['is', 'are'],\n ['was', 'were'],\n ['has', 'have'],\n ['this', 'these'],\n ['that', 'those'],\n // Words ending in with a consonant and `o`.\n ['echo', 'echoes'],\n ['dingo', 'dingoes'],\n ['volcano', 'volcanoes'],\n ['tornado', 'tornadoes'],\n ['torpedo', 'torpedoes'],\n // Ends with `us`.\n ['genus', 'genera'],\n ['viscus', 'viscera'],\n // Ends with `ma`.\n ['stigma', 'stigmata'],\n ['stoma', 'stomata'],\n ['dogma', 'dogmata'],\n ['lemma', 'lemmata'],\n ['schema', 'schemata'],\n ['anathema', 'anathemata'],\n // Other irregular rules.\n ['ox', 'oxen'],\n ['axe', 'axes'],\n ['die', 'dice'],\n ['yes', 'yeses'],\n ['foot', 'feet'],\n ['eave', 'eaves'],\n ['goose', 'geese'],\n ['tooth', 'teeth'],\n ['quiz', 'quizzes'],\n ['human', 'humans'],\n ['proof', 'proofs'],\n ['carve', 'carves'],\n ['valve', 'valves'],\n ['looey', 'looies'],\n ['thief', 'thieves'],\n ['groove', 'grooves'],\n ['pickaxe', 'pickaxes'],\n ['passerby', 'passersby']\n ].forEach(function (rule) {\n return pluralize.addIrregularRule(rule[0], rule[1]);\n });\n\n /**\n * Pluralization rules.\n */\n [\n [/s?$/i, 's'],\n [/[^\\u0000-\\u007F]$/i, '$0'],\n [/([^aeiou]ese)$/i, '$1'],\n [/(ax|test)is$/i, '$1es'],\n [/(alias|[^aou]us|t[lm]as|gas|ris)$/i, '$1es'],\n [/(e[mn]u)s?$/i, '$1s'],\n [/([^l]ias|[aeiou]las|[ejzr]as|[iu]am)$/i, '$1'],\n [/(alumn|syllab|vir|radi|nucle|fung|cact|stimul|termin|bacill|foc|uter|loc|strat)(?:us|i)$/i, '$1i'],\n [/(alumn|alg|vertebr)(?:a|ae)$/i, '$1ae'],\n [/(seraph|cherub)(?:im)?$/i, '$1im'],\n [/(her|at|gr)o$/i, '$1oes'],\n [/(agend|addend|millenni|dat|extrem|bacteri|desiderat|strat|candelabr|errat|ov|symposi|curricul|automat|quor)(?:a|um)$/i, '$1a'],\n [/(apheli|hyperbat|periheli|asyndet|noumen|phenomen|criteri|organ|prolegomen|hedr|automat)(?:a|on)$/i, '$1a'],\n [/sis$/i, 'ses'],\n [/(?:(kni|wi|li)fe|(ar|l|ea|eo|oa|hoo)f)$/i, '$1$2ves'],\n [/([^aeiouy]|qu)y$/i, '$1ies'],\n [/([^ch][ieo][ln])ey$/i, '$1ies'],\n [/(x|ch|ss|sh|zz)$/i, '$1es'],\n [/(matr|cod|mur|sil|vert|ind|append)(?:ix|ex)$/i, '$1ices'],\n [/\\b((?:tit)?m|l)(?:ice|ouse)$/i, '$1ice'],\n [/(pe)(?:rson|ople)$/i, '$1ople'],\n [/(child)(?:ren)?$/i, '$1ren'],\n [/eaux$/i, '$0'],\n [/m[ae]n$/i, 'men'],\n ['thou', 'you']\n ].forEach(function (rule) {\n return pluralize.addPluralRule(rule[0], rule[1]);\n });\n\n /**\n * Singularization rules.\n */\n [\n [/s$/i, ''],\n [/(ss)$/i, '$1'],\n [/(wi|kni|(?:after|half|high|low|mid|non|night|[^\\w]|^)li)ves$/i, '$1fe'],\n [/(ar|(?:wo|[ae])l|[eo][ao])ves$/i, '$1f'],\n [/ies$/i, 'y'],\n [/\\b([pl]|zomb|(?:neck|cross)?t|coll|faer|food|gen|goon|group|lass|talk|goal|cut)ies$/i, '$1ie'],\n [/\\b(mon|smil)ies$/i, '$1ey'],\n [/\\b((?:tit)?m|l)ice$/i, '$1ouse'],\n [/(seraph|cherub)im$/i, '$1'],\n [/(x|ch|ss|sh|zz|tto|go|cho|alias|[^aou]us|t[lm]as|gas|(?:her|at|gr)o|[aeiou]ris)(?:es)?$/i, '$1'],\n [/(analy|diagno|parenthe|progno|synop|the|empha|cri|ne)(?:sis|ses)$/i, '$1sis'],\n [/(movie|twelve|abuse|e[mn]u)s$/i, '$1'],\n [/(test)(?:is|es)$/i, '$1is'],\n [/(alumn|syllab|vir|radi|nucle|fung|cact|stimul|termin|bacill|foc|uter|loc|strat)(?:us|i)$/i, '$1us'],\n [/(agend|addend|millenni|dat|extrem|bacteri|desiderat|strat|candelabr|errat|ov|symposi|curricul|quor)a$/i, '$1um'],\n [/(apheli|hyperbat|periheli|asyndet|noumen|phenomen|criteri|organ|prolegomen|hedr|automat)a$/i, '$1on'],\n [/(alumn|alg|vertebr)ae$/i, '$1a'],\n [/(cod|mur|sil|vert|ind)ices$/i, '$1ex'],\n [/(matr|append)ices$/i, '$1ix'],\n [/(pe)(rson|ople)$/i, '$1rson'],\n [/(child)ren$/i, '$1'],\n [/(eau)x?$/i, '$1'],\n [/men$/i, 'man']\n ].forEach(function (rule) {\n return pluralize.addSingularRule(rule[0], rule[1]);\n });\n\n /**\n * Uncountable rules.\n */\n [\n // Singular words with no plurals.\n 'adulthood',\n 'advice',\n 'agenda',\n 'aid',\n 'aircraft',\n 'alcohol',\n 'ammo',\n 'analytics',\n 'anime',\n 'athletics',\n 'audio',\n 'bison',\n 'blood',\n 'bream',\n 'buffalo',\n 'butter',\n 'carp',\n 'cash',\n 'chassis',\n 'chess',\n 'clothing',\n 'cod',\n 'commerce',\n 'cooperation',\n 'corps',\n 'debris',\n 'diabetes',\n 'digestion',\n 'elk',\n 'energy',\n 'equipment',\n 'excretion',\n 'expertise',\n 'firmware',\n 'flounder',\n 'fun',\n 'gallows',\n 'garbage',\n 'graffiti',\n 'hardware',\n 'headquarters',\n 'health',\n 'herpes',\n 'highjinks',\n 'homework',\n 'housework',\n 'information',\n 'jeans',\n 'justice',\n 'kudos',\n 'labour',\n 'literature',\n 'machinery',\n 'mackerel',\n 'mail',\n 'media',\n 'mews',\n 'moose',\n 'music',\n 'mud',\n 'manga',\n 'news',\n 'only',\n 'personnel',\n 'pike',\n 'plankton',\n 'pliers',\n 'police',\n 'pollution',\n 'premises',\n 'rain',\n 'research',\n 'rice',\n 'salmon',\n 'scissors',\n 'series',\n 'sewage',\n 'shambles',\n 'shrimp',\n 'software',\n 'species',\n 'staff',\n 'swine',\n 'tennis',\n 'traffic',\n 'transportation',\n 'trout',\n 'tuna',\n 'wealth',\n 'welfare',\n 'whiting',\n 'wildebeest',\n 'wildlife',\n 'you',\n /pok[eé]mon$/i,\n // Regexes.\n /[^aeiou]ese$/i, // \"chinese\", \"japanese\"\n /deer$/i, // \"deer\", \"reindeer\"\n /fish$/i, // \"fish\", \"blowfish\", \"angelfish\"\n /measles$/i,\n /o[iu]s$/i, // \"carnivorous\"\n /pox$/i, // \"chickpox\", \"smallpox\"\n /sheep$/i\n ].forEach(pluralize.addUncountableRule);\n\n return pluralize;\n});\n","export * from './commaize'\nexport * from './pluralize'","/**\n * Adds commas to a number or string\n * @param x - The number or string to commaize\n * @returns The commaized number or string\n */\nexport const commaize = (x: number | string) => x.toString().replace(/\\B(?=(\\d{3})+(?!\\d))/g, \",\")\n","import npmPluralize from 'pluralize'\nimport { isString, isNumber } from '@art-suite/art-core-ts-types'\n\nconst patchedNpmPluralize = (noun: string, count?: number | undefined, inclusive?: boolean | undefined) => {\n const match = /^(.*?)([_\\W]+)$/.exec(noun)\n if (match) {\n const [__, mainNoun, append] = match\n const out = npmPluralize(mainNoun, count, inclusive)\n return out + append\n }\n return npmPluralize(noun, count, inclusive)\n}\n\nexport const {\n plural,\n singular,\n isSingular,\n isPlural,\n addPluralRule,\n addSingularRule,\n addIrregularRule,\n addUncountableRule,\n} = npmPluralize\n\n/**\n * Pluralize a word based on the passed in count. Call signatures:\n *\n * 1 input:\n * pluralize(singleForm: string)\n *\n * 2 inputS:\n * pluralize(singleForm: string, count: number)\n * pluralize(count: number, singleForm: string)\n *\n * 3 inputs:\n * pluralize(singleForm: string, count: number, pluralForm: string)\n * pluralize(count: number, singleForm: string, pluralForm: string)\n *\n * @param a: string | number - The word to pluralize if a string, or the count if a number\n * @param b: string | number - The count to pluralize the word by if a number, or the singleForm if a string\n * @param pluralForm: string - Explicitly provide the plural form of the word (optional)\n * @returns The pluralized word\n */\nexport const pluralize = (a: number | string, b?: number | string, pluralForm?: string) => {\n let singleForm: string\n let number: number | null = null\n if (isNumber(b)) {\n if (!isString(a)) {\n throw new Error(`singleForm and pluralForm(optional) should be non-empty strings (inputs: ${JSON.stringify({ a, b, pluralForm })}`)\n }\n singleForm = a\n number = b\n } else if (isNumber(a)) {\n if (!isString(b)) {\n throw new Error(`singleForm and pluralForm(optional) should be non-empty strings (inputs: ${JSON.stringify({ a, b, pluralForm })}`)\n }\n singleForm = b\n number = a\n } else {\n if (!isString(a)) throw new Error(`singleForm and pluralForm(optional) should be non-empty strings (inputs: ${JSON.stringify({ a, b, pluralForm })}`)\n singleForm = a\n number = null\n }\n if (pluralForm) return `${number} ${number == 1 ? singleForm : pluralForm}`\n if (number != null) return patchedNpmPluralize(singleForm, number, true)\n return patchedNpmPluralize(singleForm)\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA,8CAAAA,UAAAC,SAAA;AAAA;AAEA,KAAC,SAAU,MAAMC,YAAW;AAE1B,UAAI,OAAO,YAAY,cAAc,OAAOF,aAAY,YAAY,OAAOC,YAAW,UAAU;AAE9F,QAAAA,QAAO,UAAUC,WAAU;AAAA,MAC7B,WAAW,OAAO,WAAW,cAAc,OAAO,KAAK;AAErD,eAAO,WAAY;AACjB,iBAAOA,WAAU;AAAA,QACnB,CAAC;AAAA,MACH,OAAO;AAEL,aAAK,Y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C,GAAG;AAChB,YAAM,IAAI,MAAM,4EAA4E,KAAK,UAAU,EAAE,GAAG,GAAG,WAAW,CAAC,CAAC,EAAE;AAAA,IACpI;AACA,iBAAa;AACb,aAAS;AAAA,EACX,OAAO;AACL,QAAI,KAAC,mCAAS,CAAC,EAAG,OAAM,IAAI,MAAM,4EAA4E,KAAK,UAAU,EAAE,GAAG,GAAG,WAAW,CAAC,CAAC,EAAE;AACpJ,iBAAa;AACb,aAAS;AAAA,EACX;AACA,MAAI,WAAY,QAAO,GAAG,MAAM,IAAI,UAAU,IAAI,aAAa,UAAU;AACzE,MAAI,UAAU,KAAM,QAAO,oBAAoB,YAAY,QAAQ,IAAI;AACvE,SAAO,oBAAoB,UAAU;AACvC;","names":["exports","module","pluralize","plural","npmPluralize"]}
@@ -0,0 +1,39 @@
1
+ import npmPluralize from 'pluralize';
2
+
3
+ /**
4
+ * Adds commas to a number or string
5
+ * @param x - The number or string to commaize
6
+ * @returns The commaized number or string
7
+ */
8
+ declare const commaize: (x: number | string) => string;
9
+
10
+ declare const plural: typeof npmPluralize.plural;
11
+ declare const singular: typeof npmPluralize.singular;
12
+ declare const isSingular: typeof npmPluralize.isSingular;
13
+ declare const isPlural: typeof npmPluralize.isPlural;
14
+ declare const addPluralRule: typeof npmPluralize.addPluralRule;
15
+ declare const addSingularRule: typeof npmPluralize.addSingularRule;
16
+ declare const addIrregularRule: typeof npmPluralize.addIrregularRule;
17
+ declare const addUncountableRule: typeof npmPluralize.addUncountableRule;
18
+ /**
19
+ * Pluralize a word based on the passed in count. Call signatures:
20
+ *
21
+ * 1 input:
22
+ * pluralize(singleForm: string)
23
+ *
24
+ * 2 inputS:
25
+ * pluralize(singleForm: string, count: number)
26
+ * pluralize(count: number, singleForm: string)
27
+ *
28
+ * 3 inputs:
29
+ * pluralize(singleForm: string, count: number, pluralForm: string)
30
+ * pluralize(count: number, singleForm: string, pluralForm: string)
31
+ *
32
+ * @param a: string | number - The word to pluralize if a string, or the count if a number
33
+ * @param b: string | number - The count to pluralize the word by if a number, or the singleForm if a string
34
+ * @param pluralForm: string - Explicitly provide the plural form of the word (optional)
35
+ * @returns The pluralized word
36
+ */
37
+ declare const pluralize: (a: number | string, b?: number | string, pluralForm?: string) => string;
38
+
39
+ export { addIrregularRule, addPluralRule, addSingularRule, addUncountableRule, commaize, isPlural, isSingular, plural, pluralize, singular };
@@ -0,0 +1,39 @@
1
+ import npmPluralize from 'pluralize';
2
+
3
+ /**
4
+ * Adds commas to a number or string
5
+ * @param x - The number or string to commaize
6
+ * @returns The commaized number or string
7
+ */
8
+ declare const commaize: (x: number | string) => string;
9
+
10
+ declare const plural: typeof npmPluralize.plural;
11
+ declare const singular: typeof npmPluralize.singular;
12
+ declare const isSingular: typeof npmPluralize.isSingular;
13
+ declare const isPlural: typeof npmPluralize.isPlural;
14
+ declare const addPluralRule: typeof npmPluralize.addPluralRule;
15
+ declare const addSingularRule: typeof npmPluralize.addSingularRule;
16
+ declare const addIrregularRule: typeof npmPluralize.addIrregularRule;
17
+ declare const addUncountableRule: typeof npmPluralize.addUncountableRule;
18
+ /**
19
+ * Pluralize a word based on the passed in count. Call signatures:
20
+ *
21
+ * 1 input:
22
+ * pluralize(singleForm: string)
23
+ *
24
+ * 2 inputS:
25
+ * pluralize(singleForm: string, count: number)
26
+ * pluralize(count: number, singleForm: string)
27
+ *
28
+ * 3 inputs:
29
+ * pluralize(singleForm: string, count: number, pluralForm: string)
30
+ * pluralize(count: number, singleForm: string, pluralForm: string)
31
+ *
32
+ * @param a: string | number - The word to pluralize if a string, or the count if a number
33
+ * @param b: string | number - The count to pluralize the word by if a number, or the singleForm if a string
34
+ * @param pluralForm: string - Explicitly provide the plural form of the word (optional)
35
+ * @returns The pluralized word
36
+ */
37
+ declare const pluralize: (a: number | string, b?: number | string, pluralForm?: string) => string;
38
+
39
+ export { addIrregularRule, addPluralRule, addSingularRule, addUncountableRule, commaize, isPlural, isSingular, plural, pluralize, singular };
package/dist/index.js ADDED
@@ -0,0 +1,446 @@
1
+ var __create = Object.create;
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __getProtoOf = Object.getPrototypeOf;
6
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
7
+ var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require : typeof Proxy !== "undefined" ? new Proxy(x, {
8
+ get: (a, b) => (typeof require !== "undefined" ? require : a)[b]
9
+ }) : x)(function(x) {
10
+ if (typeof require !== "undefined") return require.apply(this, arguments);
11
+ throw Error('Dynamic require of "' + x + '" is not supported');
12
+ });
13
+ var __commonJS = (cb, mod) => function __require2() {
14
+ return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
15
+ };
16
+ var __copyProps = (to, from, except, desc) => {
17
+ if (from && typeof from === "object" || typeof from === "function") {
18
+ for (let key of __getOwnPropNames(from))
19
+ if (!__hasOwnProp.call(to, key) && key !== except)
20
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
21
+ }
22
+ return to;
23
+ };
24
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
25
+ // If the importer is in node compatibility mode or this is not an ESM
26
+ // file that has been converted to a CommonJS file using a Babel-
27
+ // compatible transform (i.e. "__esModule" has not been set), then set
28
+ // "default" to the CommonJS "module.exports" for node compatibility.
29
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
30
+ mod
31
+ ));
32
+
33
+ // ../../node_modules/pluralize/pluralize.js
34
+ var require_pluralize = __commonJS({
35
+ "../../node_modules/pluralize/pluralize.js"(exports, module) {
36
+ "use strict";
37
+ (function(root, pluralize2) {
38
+ if (typeof __require === "function" && typeof exports === "object" && typeof module === "object") {
39
+ module.exports = pluralize2();
40
+ } else if (typeof define === "function" && define.amd) {
41
+ define(function() {
42
+ return pluralize2();
43
+ });
44
+ } else {
45
+ root.pluralize = pluralize2();
46
+ }
47
+ })(exports, function() {
48
+ var pluralRules = [];
49
+ var singularRules = [];
50
+ var uncountables = {};
51
+ var irregularPlurals = {};
52
+ var irregularSingles = {};
53
+ function sanitizeRule(rule) {
54
+ if (typeof rule === "string") {
55
+ return new RegExp("^" + rule + "$", "i");
56
+ }
57
+ return rule;
58
+ }
59
+ function restoreCase(word, token) {
60
+ if (word === token) return token;
61
+ if (word === word.toLowerCase()) return token.toLowerCase();
62
+ if (word === word.toUpperCase()) return token.toUpperCase();
63
+ if (word[0] === word[0].toUpperCase()) {
64
+ return token.charAt(0).toUpperCase() + token.substr(1).toLowerCase();
65
+ }
66
+ return token.toLowerCase();
67
+ }
68
+ function interpolate(str, args) {
69
+ return str.replace(/\$(\d{1,2})/g, function(match, index) {
70
+ return args[index] || "";
71
+ });
72
+ }
73
+ function replace(word, rule) {
74
+ return word.replace(rule[0], function(match, index) {
75
+ var result = interpolate(rule[1], arguments);
76
+ if (match === "") {
77
+ return restoreCase(word[index - 1], result);
78
+ }
79
+ return restoreCase(match, result);
80
+ });
81
+ }
82
+ function sanitizeWord(token, word, rules) {
83
+ if (!token.length || uncountables.hasOwnProperty(token)) {
84
+ return word;
85
+ }
86
+ var len = rules.length;
87
+ while (len--) {
88
+ var rule = rules[len];
89
+ if (rule[0].test(word)) return replace(word, rule);
90
+ }
91
+ return word;
92
+ }
93
+ function replaceWord(replaceMap, keepMap, rules) {
94
+ return function(word) {
95
+ var token = word.toLowerCase();
96
+ if (keepMap.hasOwnProperty(token)) {
97
+ return restoreCase(word, token);
98
+ }
99
+ if (replaceMap.hasOwnProperty(token)) {
100
+ return restoreCase(word, replaceMap[token]);
101
+ }
102
+ return sanitizeWord(token, word, rules);
103
+ };
104
+ }
105
+ function checkWord(replaceMap, keepMap, rules, bool) {
106
+ return function(word) {
107
+ var token = word.toLowerCase();
108
+ if (keepMap.hasOwnProperty(token)) return true;
109
+ if (replaceMap.hasOwnProperty(token)) return false;
110
+ return sanitizeWord(token, token, rules) === token;
111
+ };
112
+ }
113
+ function pluralize2(word, count, inclusive) {
114
+ var pluralized = count === 1 ? pluralize2.singular(word) : pluralize2.plural(word);
115
+ return (inclusive ? count + " " : "") + pluralized;
116
+ }
117
+ pluralize2.plural = replaceWord(
118
+ irregularSingles,
119
+ irregularPlurals,
120
+ pluralRules
121
+ );
122
+ pluralize2.isPlural = checkWord(
123
+ irregularSingles,
124
+ irregularPlurals,
125
+ pluralRules
126
+ );
127
+ pluralize2.singular = replaceWord(
128
+ irregularPlurals,
129
+ irregularSingles,
130
+ singularRules
131
+ );
132
+ pluralize2.isSingular = checkWord(
133
+ irregularPlurals,
134
+ irregularSingles,
135
+ singularRules
136
+ );
137
+ pluralize2.addPluralRule = function(rule, replacement) {
138
+ pluralRules.push([sanitizeRule(rule), replacement]);
139
+ };
140
+ pluralize2.addSingularRule = function(rule, replacement) {
141
+ singularRules.push([sanitizeRule(rule), replacement]);
142
+ };
143
+ pluralize2.addUncountableRule = function(word) {
144
+ if (typeof word === "string") {
145
+ uncountables[word.toLowerCase()] = true;
146
+ return;
147
+ }
148
+ pluralize2.addPluralRule(word, "$0");
149
+ pluralize2.addSingularRule(word, "$0");
150
+ };
151
+ pluralize2.addIrregularRule = function(single, plural2) {
152
+ plural2 = plural2.toLowerCase();
153
+ single = single.toLowerCase();
154
+ irregularSingles[single] = plural2;
155
+ irregularPlurals[plural2] = single;
156
+ };
157
+ [
158
+ // Pronouns.
159
+ ["I", "we"],
160
+ ["me", "us"],
161
+ ["he", "they"],
162
+ ["she", "they"],
163
+ ["them", "them"],
164
+ ["myself", "ourselves"],
165
+ ["yourself", "yourselves"],
166
+ ["itself", "themselves"],
167
+ ["herself", "themselves"],
168
+ ["himself", "themselves"],
169
+ ["themself", "themselves"],
170
+ ["is", "are"],
171
+ ["was", "were"],
172
+ ["has", "have"],
173
+ ["this", "these"],
174
+ ["that", "those"],
175
+ // Words ending in with a consonant and `o`.
176
+ ["echo", "echoes"],
177
+ ["dingo", "dingoes"],
178
+ ["volcano", "volcanoes"],
179
+ ["tornado", "tornadoes"],
180
+ ["torpedo", "torpedoes"],
181
+ // Ends with `us`.
182
+ ["genus", "genera"],
183
+ ["viscus", "viscera"],
184
+ // Ends with `ma`.
185
+ ["stigma", "stigmata"],
186
+ ["stoma", "stomata"],
187
+ ["dogma", "dogmata"],
188
+ ["lemma", "lemmata"],
189
+ ["schema", "schemata"],
190
+ ["anathema", "anathemata"],
191
+ // Other irregular rules.
192
+ ["ox", "oxen"],
193
+ ["axe", "axes"],
194
+ ["die", "dice"],
195
+ ["yes", "yeses"],
196
+ ["foot", "feet"],
197
+ ["eave", "eaves"],
198
+ ["goose", "geese"],
199
+ ["tooth", "teeth"],
200
+ ["quiz", "quizzes"],
201
+ ["human", "humans"],
202
+ ["proof", "proofs"],
203
+ ["carve", "carves"],
204
+ ["valve", "valves"],
205
+ ["looey", "looies"],
206
+ ["thief", "thieves"],
207
+ ["groove", "grooves"],
208
+ ["pickaxe", "pickaxes"],
209
+ ["passerby", "passersby"]
210
+ ].forEach(function(rule) {
211
+ return pluralize2.addIrregularRule(rule[0], rule[1]);
212
+ });
213
+ [
214
+ [/s?$/i, "s"],
215
+ [/[^\u0000-\u007F]$/i, "$0"],
216
+ [/([^aeiou]ese)$/i, "$1"],
217
+ [/(ax|test)is$/i, "$1es"],
218
+ [/(alias|[^aou]us|t[lm]as|gas|ris)$/i, "$1es"],
219
+ [/(e[mn]u)s?$/i, "$1s"],
220
+ [/([^l]ias|[aeiou]las|[ejzr]as|[iu]am)$/i, "$1"],
221
+ [/(alumn|syllab|vir|radi|nucle|fung|cact|stimul|termin|bacill|foc|uter|loc|strat)(?:us|i)$/i, "$1i"],
222
+ [/(alumn|alg|vertebr)(?:a|ae)$/i, "$1ae"],
223
+ [/(seraph|cherub)(?:im)?$/i, "$1im"],
224
+ [/(her|at|gr)o$/i, "$1oes"],
225
+ [/(agend|addend|millenni|dat|extrem|bacteri|desiderat|strat|candelabr|errat|ov|symposi|curricul|automat|quor)(?:a|um)$/i, "$1a"],
226
+ [/(apheli|hyperbat|periheli|asyndet|noumen|phenomen|criteri|organ|prolegomen|hedr|automat)(?:a|on)$/i, "$1a"],
227
+ [/sis$/i, "ses"],
228
+ [/(?:(kni|wi|li)fe|(ar|l|ea|eo|oa|hoo)f)$/i, "$1$2ves"],
229
+ [/([^aeiouy]|qu)y$/i, "$1ies"],
230
+ [/([^ch][ieo][ln])ey$/i, "$1ies"],
231
+ [/(x|ch|ss|sh|zz)$/i, "$1es"],
232
+ [/(matr|cod|mur|sil|vert|ind|append)(?:ix|ex)$/i, "$1ices"],
233
+ [/\b((?:tit)?m|l)(?:ice|ouse)$/i, "$1ice"],
234
+ [/(pe)(?:rson|ople)$/i, "$1ople"],
235
+ [/(child)(?:ren)?$/i, "$1ren"],
236
+ [/eaux$/i, "$0"],
237
+ [/m[ae]n$/i, "men"],
238
+ ["thou", "you"]
239
+ ].forEach(function(rule) {
240
+ return pluralize2.addPluralRule(rule[0], rule[1]);
241
+ });
242
+ [
243
+ [/s$/i, ""],
244
+ [/(ss)$/i, "$1"],
245
+ [/(wi|kni|(?:after|half|high|low|mid|non|night|[^\w]|^)li)ves$/i, "$1fe"],
246
+ [/(ar|(?:wo|[ae])l|[eo][ao])ves$/i, "$1f"],
247
+ [/ies$/i, "y"],
248
+ [/\b([pl]|zomb|(?:neck|cross)?t|coll|faer|food|gen|goon|group|lass|talk|goal|cut)ies$/i, "$1ie"],
249
+ [/\b(mon|smil)ies$/i, "$1ey"],
250
+ [/\b((?:tit)?m|l)ice$/i, "$1ouse"],
251
+ [/(seraph|cherub)im$/i, "$1"],
252
+ [/(x|ch|ss|sh|zz|tto|go|cho|alias|[^aou]us|t[lm]as|gas|(?:her|at|gr)o|[aeiou]ris)(?:es)?$/i, "$1"],
253
+ [/(analy|diagno|parenthe|progno|synop|the|empha|cri|ne)(?:sis|ses)$/i, "$1sis"],
254
+ [/(movie|twelve|abuse|e[mn]u)s$/i, "$1"],
255
+ [/(test)(?:is|es)$/i, "$1is"],
256
+ [/(alumn|syllab|vir|radi|nucle|fung|cact|stimul|termin|bacill|foc|uter|loc|strat)(?:us|i)$/i, "$1us"],
257
+ [/(agend|addend|millenni|dat|extrem|bacteri|desiderat|strat|candelabr|errat|ov|symposi|curricul|quor)a$/i, "$1um"],
258
+ [/(apheli|hyperbat|periheli|asyndet|noumen|phenomen|criteri|organ|prolegomen|hedr|automat)a$/i, "$1on"],
259
+ [/(alumn|alg|vertebr)ae$/i, "$1a"],
260
+ [/(cod|mur|sil|vert|ind)ices$/i, "$1ex"],
261
+ [/(matr|append)ices$/i, "$1ix"],
262
+ [/(pe)(rson|ople)$/i, "$1rson"],
263
+ [/(child)ren$/i, "$1"],
264
+ [/(eau)x?$/i, "$1"],
265
+ [/men$/i, "man"]
266
+ ].forEach(function(rule) {
267
+ return pluralize2.addSingularRule(rule[0], rule[1]);
268
+ });
269
+ [
270
+ // Singular words with no plurals.
271
+ "adulthood",
272
+ "advice",
273
+ "agenda",
274
+ "aid",
275
+ "aircraft",
276
+ "alcohol",
277
+ "ammo",
278
+ "analytics",
279
+ "anime",
280
+ "athletics",
281
+ "audio",
282
+ "bison",
283
+ "blood",
284
+ "bream",
285
+ "buffalo",
286
+ "butter",
287
+ "carp",
288
+ "cash",
289
+ "chassis",
290
+ "chess",
291
+ "clothing",
292
+ "cod",
293
+ "commerce",
294
+ "cooperation",
295
+ "corps",
296
+ "debris",
297
+ "diabetes",
298
+ "digestion",
299
+ "elk",
300
+ "energy",
301
+ "equipment",
302
+ "excretion",
303
+ "expertise",
304
+ "firmware",
305
+ "flounder",
306
+ "fun",
307
+ "gallows",
308
+ "garbage",
309
+ "graffiti",
310
+ "hardware",
311
+ "headquarters",
312
+ "health",
313
+ "herpes",
314
+ "highjinks",
315
+ "homework",
316
+ "housework",
317
+ "information",
318
+ "jeans",
319
+ "justice",
320
+ "kudos",
321
+ "labour",
322
+ "literature",
323
+ "machinery",
324
+ "mackerel",
325
+ "mail",
326
+ "media",
327
+ "mews",
328
+ "moose",
329
+ "music",
330
+ "mud",
331
+ "manga",
332
+ "news",
333
+ "only",
334
+ "personnel",
335
+ "pike",
336
+ "plankton",
337
+ "pliers",
338
+ "police",
339
+ "pollution",
340
+ "premises",
341
+ "rain",
342
+ "research",
343
+ "rice",
344
+ "salmon",
345
+ "scissors",
346
+ "series",
347
+ "sewage",
348
+ "shambles",
349
+ "shrimp",
350
+ "software",
351
+ "species",
352
+ "staff",
353
+ "swine",
354
+ "tennis",
355
+ "traffic",
356
+ "transportation",
357
+ "trout",
358
+ "tuna",
359
+ "wealth",
360
+ "welfare",
361
+ "whiting",
362
+ "wildebeest",
363
+ "wildlife",
364
+ "you",
365
+ /pok[eé]mon$/i,
366
+ // Regexes.
367
+ /[^aeiou]ese$/i,
368
+ // "chinese", "japanese"
369
+ /deer$/i,
370
+ // "deer", "reindeer"
371
+ /fish$/i,
372
+ // "fish", "blowfish", "angelfish"
373
+ /measles$/i,
374
+ /o[iu]s$/i,
375
+ // "carnivorous"
376
+ /pox$/i,
377
+ // "chickpox", "smallpox"
378
+ /sheep$/i
379
+ ].forEach(pluralize2.addUncountableRule);
380
+ return pluralize2;
381
+ });
382
+ }
383
+ });
384
+
385
+ // src/commaize.ts
386
+ var commaize = (x) => x.toString().replace(/\B(?=(\d{3})+(?!\d))/g, ",");
387
+
388
+ // src/pluralize.ts
389
+ var import_pluralize = __toESM(require_pluralize(), 1);
390
+ import { isString, isNumber } from "@art-suite/art-core-ts-types";
391
+ var patchedNpmPluralize = (noun, count, inclusive) => {
392
+ const match = /^(.*?)([_\W]+)$/.exec(noun);
393
+ if (match) {
394
+ const [__, mainNoun, append] = match;
395
+ const out = (0, import_pluralize.default)(mainNoun, count, inclusive);
396
+ return out + append;
397
+ }
398
+ return (0, import_pluralize.default)(noun, count, inclusive);
399
+ };
400
+ var {
401
+ plural,
402
+ singular,
403
+ isSingular,
404
+ isPlural,
405
+ addPluralRule,
406
+ addSingularRule,
407
+ addIrregularRule,
408
+ addUncountableRule
409
+ } = import_pluralize.default;
410
+ var pluralize = (a, b, pluralForm) => {
411
+ let singleForm;
412
+ let number = null;
413
+ if (isNumber(b)) {
414
+ if (!isString(a)) {
415
+ throw new Error(`singleForm and pluralForm(optional) should be non-empty strings (inputs: ${JSON.stringify({ a, b, pluralForm })}`);
416
+ }
417
+ singleForm = a;
418
+ number = b;
419
+ } else if (isNumber(a)) {
420
+ if (!isString(b)) {
421
+ throw new Error(`singleForm and pluralForm(optional) should be non-empty strings (inputs: ${JSON.stringify({ a, b, pluralForm })}`);
422
+ }
423
+ singleForm = b;
424
+ number = a;
425
+ } else {
426
+ if (!isString(a)) throw new Error(`singleForm and pluralForm(optional) should be non-empty strings (inputs: ${JSON.stringify({ a, b, pluralForm })}`);
427
+ singleForm = a;
428
+ number = null;
429
+ }
430
+ if (pluralForm) return `${number} ${number == 1 ? singleForm : pluralForm}`;
431
+ if (number != null) return patchedNpmPluralize(singleForm, number, true);
432
+ return patchedNpmPluralize(singleForm);
433
+ };
434
+ export {
435
+ addIrregularRule,
436
+ addPluralRule,
437
+ addSingularRule,
438
+ addUncountableRule,
439
+ commaize,
440
+ isPlural,
441
+ isSingular,
442
+ plural,
443
+ pluralize,
444
+ singular
445
+ };
446
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../node_modules/pluralize/pluralize.js","../src/commaize.ts","../src/pluralize.ts"],"sourcesContent":["/* global define */\n\n(function (root, pluralize) {\n /* istanbul ignore else */\n if (typeof require === 'function' && typeof exports === 'object' && typeof module === 'object') {\n // Node.\n module.exports = pluralize();\n } else if (typeof define === 'function' && define.amd) {\n // AMD, registers as an anonymous module.\n define(function () {\n return pluralize();\n });\n } else {\n // Browser global.\n root.pluralize = pluralize();\n }\n})(this, function () {\n // Rule storage - pluralize and singularize need to be run sequentially,\n // while other rules can be optimized using an object for instant lookups.\n var pluralRules = [];\n var singularRules = [];\n var uncountables = {};\n var irregularPlurals = {};\n var irregularSingles = {};\n\n /**\n * Sanitize a pluralization rule to a usable regular expression.\n *\n * @param {(RegExp|string)} rule\n * @return {RegExp}\n */\n function sanitizeRule (rule) {\n if (typeof rule === 'string') {\n return new RegExp('^' + rule + '$', 'i');\n }\n\n return rule;\n }\n\n /**\n * Pass in a word token to produce a function that can replicate the case on\n * another word.\n *\n * @param {string} word\n * @param {string} token\n * @return {Function}\n */\n function restoreCase (word, token) {\n // Tokens are an exact match.\n if (word === token) return token;\n\n // Lower cased words. E.g. \"hello\".\n if (word === word.toLowerCase()) return token.toLowerCase();\n\n // Upper cased words. E.g. \"WHISKY\".\n if (word === word.toUpperCase()) return token.toUpperCase();\n\n // Title cased words. E.g. \"Title\".\n if (word[0] === word[0].toUpperCase()) {\n return token.charAt(0).toUpperCase() + token.substr(1).toLowerCase();\n }\n\n // Lower cased words. E.g. \"test\".\n return token.toLowerCase();\n }\n\n /**\n * Interpolate a regexp string.\n *\n * @param {string} str\n * @param {Array} args\n * @return {string}\n */\n function interpolate (str, args) {\n return str.replace(/\\$(\\d{1,2})/g, function (match, index) {\n return args[index] || '';\n });\n }\n\n /**\n * Replace a word using a rule.\n *\n * @param {string} word\n * @param {Array} rule\n * @return {string}\n */\n function replace (word, rule) {\n return word.replace(rule[0], function (match, index) {\n var result = interpolate(rule[1], arguments);\n\n if (match === '') {\n return restoreCase(word[index - 1], result);\n }\n\n return restoreCase(match, result);\n });\n }\n\n /**\n * Sanitize a word by passing in the word and sanitization rules.\n *\n * @param {string} token\n * @param {string} word\n * @param {Array} rules\n * @return {string}\n */\n function sanitizeWord (token, word, rules) {\n // Empty string or doesn't need fixing.\n if (!token.length || uncountables.hasOwnProperty(token)) {\n return word;\n }\n\n var len = rules.length;\n\n // Iterate over the sanitization rules and use the first one to match.\n while (len--) {\n var rule = rules[len];\n\n if (rule[0].test(word)) return replace(word, rule);\n }\n\n return word;\n }\n\n /**\n * Replace a word with the updated word.\n *\n * @param {Object} replaceMap\n * @param {Object} keepMap\n * @param {Array} rules\n * @return {Function}\n */\n function replaceWord (replaceMap, keepMap, rules) {\n return function (word) {\n // Get the correct token and case restoration functions.\n var token = word.toLowerCase();\n\n // Check against the keep object map.\n if (keepMap.hasOwnProperty(token)) {\n return restoreCase(word, token);\n }\n\n // Check against the replacement map for a direct word replacement.\n if (replaceMap.hasOwnProperty(token)) {\n return restoreCase(word, replaceMap[token]);\n }\n\n // Run all the rules against the word.\n return sanitizeWord(token, word, rules);\n };\n }\n\n /**\n * Check if a word is part of the map.\n */\n function checkWord (replaceMap, keepMap, rules, bool) {\n return function (word) {\n var token = word.toLowerCase();\n\n if (keepMap.hasOwnProperty(token)) return true;\n if (replaceMap.hasOwnProperty(token)) return false;\n\n return sanitizeWord(token, token, rules) === token;\n };\n }\n\n /**\n * Pluralize or singularize a word based on the passed in count.\n *\n * @param {string} word The word to pluralize\n * @param {number} count How many of the word exist\n * @param {boolean} inclusive Whether to prefix with the number (e.g. 3 ducks)\n * @return {string}\n */\n function pluralize (word, count, inclusive) {\n var pluralized = count === 1\n ? pluralize.singular(word) : pluralize.plural(word);\n\n return (inclusive ? count + ' ' : '') + pluralized;\n }\n\n /**\n * Pluralize a word.\n *\n * @type {Function}\n */\n pluralize.plural = replaceWord(\n irregularSingles, irregularPlurals, pluralRules\n );\n\n /**\n * Check if a word is plural.\n *\n * @type {Function}\n */\n pluralize.isPlural = checkWord(\n irregularSingles, irregularPlurals, pluralRules\n );\n\n /**\n * Singularize a word.\n *\n * @type {Function}\n */\n pluralize.singular = replaceWord(\n irregularPlurals, irregularSingles, singularRules\n );\n\n /**\n * Check if a word is singular.\n *\n * @type {Function}\n */\n pluralize.isSingular = checkWord(\n irregularPlurals, irregularSingles, singularRules\n );\n\n /**\n * Add a pluralization rule to the collection.\n *\n * @param {(string|RegExp)} rule\n * @param {string} replacement\n */\n pluralize.addPluralRule = function (rule, replacement) {\n pluralRules.push([sanitizeRule(rule), replacement]);\n };\n\n /**\n * Add a singularization rule to the collection.\n *\n * @param {(string|RegExp)} rule\n * @param {string} replacement\n */\n pluralize.addSingularRule = function (rule, replacement) {\n singularRules.push([sanitizeRule(rule), replacement]);\n };\n\n /**\n * Add an uncountable word rule.\n *\n * @param {(string|RegExp)} word\n */\n pluralize.addUncountableRule = function (word) {\n if (typeof word === 'string') {\n uncountables[word.toLowerCase()] = true;\n return;\n }\n\n // Set singular and plural references for the word.\n pluralize.addPluralRule(word, '$0');\n pluralize.addSingularRule(word, '$0');\n };\n\n /**\n * Add an irregular word definition.\n *\n * @param {string} single\n * @param {string} plural\n */\n pluralize.addIrregularRule = function (single, plural) {\n plural = plural.toLowerCase();\n single = single.toLowerCase();\n\n irregularSingles[single] = plural;\n irregularPlurals[plural] = single;\n };\n\n /**\n * Irregular rules.\n */\n [\n // Pronouns.\n ['I', 'we'],\n ['me', 'us'],\n ['he', 'they'],\n ['she', 'they'],\n ['them', 'them'],\n ['myself', 'ourselves'],\n ['yourself', 'yourselves'],\n ['itself', 'themselves'],\n ['herself', 'themselves'],\n ['himself', 'themselves'],\n ['themself', 'themselves'],\n ['is', 'are'],\n ['was', 'were'],\n ['has', 'have'],\n ['this', 'these'],\n ['that', 'those'],\n // Words ending in with a consonant and `o`.\n ['echo', 'echoes'],\n ['dingo', 'dingoes'],\n ['volcano', 'volcanoes'],\n ['tornado', 'tornadoes'],\n ['torpedo', 'torpedoes'],\n // Ends with `us`.\n ['genus', 'genera'],\n ['viscus', 'viscera'],\n // Ends with `ma`.\n ['stigma', 'stigmata'],\n ['stoma', 'stomata'],\n ['dogma', 'dogmata'],\n ['lemma', 'lemmata'],\n ['schema', 'schemata'],\n ['anathema', 'anathemata'],\n // Other irregular rules.\n ['ox', 'oxen'],\n ['axe', 'axes'],\n ['die', 'dice'],\n ['yes', 'yeses'],\n ['foot', 'feet'],\n ['eave', 'eaves'],\n ['goose', 'geese'],\n ['tooth', 'teeth'],\n ['quiz', 'quizzes'],\n ['human', 'humans'],\n ['proof', 'proofs'],\n ['carve', 'carves'],\n ['valve', 'valves'],\n ['looey', 'looies'],\n ['thief', 'thieves'],\n ['groove', 'grooves'],\n ['pickaxe', 'pickaxes'],\n ['passerby', 'passersby']\n ].forEach(function (rule) {\n return pluralize.addIrregularRule(rule[0], rule[1]);\n });\n\n /**\n * Pluralization rules.\n */\n [\n [/s?$/i, 's'],\n [/[^\\u0000-\\u007F]$/i, '$0'],\n [/([^aeiou]ese)$/i, '$1'],\n [/(ax|test)is$/i, '$1es'],\n [/(alias|[^aou]us|t[lm]as|gas|ris)$/i, '$1es'],\n [/(e[mn]u)s?$/i, '$1s'],\n [/([^l]ias|[aeiou]las|[ejzr]as|[iu]am)$/i, '$1'],\n [/(alumn|syllab|vir|radi|nucle|fung|cact|stimul|termin|bacill|foc|uter|loc|strat)(?:us|i)$/i, '$1i'],\n [/(alumn|alg|vertebr)(?:a|ae)$/i, '$1ae'],\n [/(seraph|cherub)(?:im)?$/i, '$1im'],\n [/(her|at|gr)o$/i, '$1oes'],\n [/(agend|addend|millenni|dat|extrem|bacteri|desiderat|strat|candelabr|errat|ov|symposi|curricul|automat|quor)(?:a|um)$/i, '$1a'],\n [/(apheli|hyperbat|periheli|asyndet|noumen|phenomen|criteri|organ|prolegomen|hedr|automat)(?:a|on)$/i, '$1a'],\n [/sis$/i, 'ses'],\n [/(?:(kni|wi|li)fe|(ar|l|ea|eo|oa|hoo)f)$/i, '$1$2ves'],\n [/([^aeiouy]|qu)y$/i, '$1ies'],\n [/([^ch][ieo][ln])ey$/i, '$1ies'],\n [/(x|ch|ss|sh|zz)$/i, '$1es'],\n [/(matr|cod|mur|sil|vert|ind|append)(?:ix|ex)$/i, '$1ices'],\n [/\\b((?:tit)?m|l)(?:ice|ouse)$/i, '$1ice'],\n [/(pe)(?:rson|ople)$/i, '$1ople'],\n [/(child)(?:ren)?$/i, '$1ren'],\n [/eaux$/i, '$0'],\n [/m[ae]n$/i, 'men'],\n ['thou', 'you']\n ].forEach(function (rule) {\n return pluralize.addPluralRule(rule[0], rule[1]);\n });\n\n /**\n * Singularization rules.\n */\n [\n [/s$/i, ''],\n [/(ss)$/i, '$1'],\n [/(wi|kni|(?:after|half|high|low|mid|non|night|[^\\w]|^)li)ves$/i, '$1fe'],\n [/(ar|(?:wo|[ae])l|[eo][ao])ves$/i, '$1f'],\n [/ies$/i, 'y'],\n [/\\b([pl]|zomb|(?:neck|cross)?t|coll|faer|food|gen|goon|group|lass|talk|goal|cut)ies$/i, '$1ie'],\n [/\\b(mon|smil)ies$/i, '$1ey'],\n [/\\b((?:tit)?m|l)ice$/i, '$1ouse'],\n [/(seraph|cherub)im$/i, '$1'],\n [/(x|ch|ss|sh|zz|tto|go|cho|alias|[^aou]us|t[lm]as|gas|(?:her|at|gr)o|[aeiou]ris)(?:es)?$/i, '$1'],\n [/(analy|diagno|parenthe|progno|synop|the|empha|cri|ne)(?:sis|ses)$/i, '$1sis'],\n [/(movie|twelve|abuse|e[mn]u)s$/i, '$1'],\n [/(test)(?:is|es)$/i, '$1is'],\n [/(alumn|syllab|vir|radi|nucle|fung|cact|stimul|termin|bacill|foc|uter|loc|strat)(?:us|i)$/i, '$1us'],\n [/(agend|addend|millenni|dat|extrem|bacteri|desiderat|strat|candelabr|errat|ov|symposi|curricul|quor)a$/i, '$1um'],\n [/(apheli|hyperbat|periheli|asyndet|noumen|phenomen|criteri|organ|prolegomen|hedr|automat)a$/i, '$1on'],\n [/(alumn|alg|vertebr)ae$/i, '$1a'],\n [/(cod|mur|sil|vert|ind)ices$/i, '$1ex'],\n [/(matr|append)ices$/i, '$1ix'],\n [/(pe)(rson|ople)$/i, '$1rson'],\n [/(child)ren$/i, '$1'],\n [/(eau)x?$/i, '$1'],\n [/men$/i, 'man']\n ].forEach(function (rule) {\n return pluralize.addSingularRule(rule[0], rule[1]);\n });\n\n /**\n * Uncountable rules.\n */\n [\n // Singular words with no plurals.\n 'adulthood',\n 'advice',\n 'agenda',\n 'aid',\n 'aircraft',\n 'alcohol',\n 'ammo',\n 'analytics',\n 'anime',\n 'athletics',\n 'audio',\n 'bison',\n 'blood',\n 'bream',\n 'buffalo',\n 'butter',\n 'carp',\n 'cash',\n 'chassis',\n 'chess',\n 'clothing',\n 'cod',\n 'commerce',\n 'cooperation',\n 'corps',\n 'debris',\n 'diabetes',\n 'digestion',\n 'elk',\n 'energy',\n 'equipment',\n 'excretion',\n 'expertise',\n 'firmware',\n 'flounder',\n 'fun',\n 'gallows',\n 'garbage',\n 'graffiti',\n 'hardware',\n 'headquarters',\n 'health',\n 'herpes',\n 'highjinks',\n 'homework',\n 'housework',\n 'information',\n 'jeans',\n 'justice',\n 'kudos',\n 'labour',\n 'literature',\n 'machinery',\n 'mackerel',\n 'mail',\n 'media',\n 'mews',\n 'moose',\n 'music',\n 'mud',\n 'manga',\n 'news',\n 'only',\n 'personnel',\n 'pike',\n 'plankton',\n 'pliers',\n 'police',\n 'pollution',\n 'premises',\n 'rain',\n 'research',\n 'rice',\n 'salmon',\n 'scissors',\n 'series',\n 'sewage',\n 'shambles',\n 'shrimp',\n 'software',\n 'species',\n 'staff',\n 'swine',\n 'tennis',\n 'traffic',\n 'transportation',\n 'trout',\n 'tuna',\n 'wealth',\n 'welfare',\n 'whiting',\n 'wildebeest',\n 'wildlife',\n 'you',\n /pok[eé]mon$/i,\n // Regexes.\n /[^aeiou]ese$/i, // \"chinese\", \"japanese\"\n /deer$/i, // \"deer\", \"reindeer\"\n /fish$/i, // \"fish\", \"blowfish\", \"angelfish\"\n /measles$/i,\n /o[iu]s$/i, // \"carnivorous\"\n /pox$/i, // \"chickpox\", \"smallpox\"\n /sheep$/i\n ].forEach(pluralize.addUncountableRule);\n\n return pluralize;\n});\n","/**\n * Adds commas to a number or string\n * @param x - The number or string to commaize\n * @returns The commaized number or string\n */\nexport const commaize = (x: number | string) => x.toString().replace(/\\B(?=(\\d{3})+(?!\\d))/g, \",\")\n","import npmPluralize from 'pluralize'\nimport { isString, isNumber } from '@art-suite/art-core-ts-types'\n\nconst patchedNpmPluralize = (noun: string, count?: number | undefined, inclusive?: boolean | undefined) => {\n const match = /^(.*?)([_\\W]+)$/.exec(noun)\n if (match) {\n const [__, mainNoun, append] = match\n const out = npmPluralize(mainNoun, count, inclusive)\n return out + append\n }\n return npmPluralize(noun, count, inclusive)\n}\n\nexport const {\n plural,\n singular,\n isSingular,\n isPlural,\n addPluralRule,\n addSingularRule,\n addIrregularRule,\n addUncountableRule,\n} = npmPluralize\n\n/**\n * Pluralize a word based on the passed in count. Call signatures:\n *\n * 1 input:\n * pluralize(singleForm: string)\n *\n * 2 inputS:\n * pluralize(singleForm: string, count: number)\n * pluralize(count: number, singleForm: string)\n *\n * 3 inputs:\n * pluralize(singleForm: string, count: number, pluralForm: string)\n * pluralize(count: number, singleForm: string, pluralForm: string)\n *\n * @param a: string | number - The word to pluralize if a string, or the count if a number\n * @param b: string | number - The count to pluralize the word by if a number, or the singleForm if a string\n * @param pluralForm: string - Explicitly provide the plural form of the word (optional)\n * @returns The pluralized word\n */\nexport const pluralize = (a: number | string, b?: number | string, pluralForm?: string) => {\n let singleForm: string\n let number: number | null = null\n if (isNumber(b)) {\n if (!isString(a)) {\n throw new Error(`singleForm and pluralForm(optional) should be non-empty strings (inputs: ${JSON.stringify({ a, b, pluralForm })}`)\n }\n singleForm = a\n number = b\n } else if (isNumber(a)) {\n if (!isString(b)) {\n throw new Error(`singleForm and pluralForm(optional) should be non-empty strings (inputs: ${JSON.stringify({ a, b, pluralForm })}`)\n }\n singleForm = b\n number = a\n } else {\n if (!isString(a)) throw new Error(`singleForm and pluralForm(optional) should be non-empty strings (inputs: ${JSON.stringify({ a, b, pluralForm })}`)\n singleForm = a\n number = null\n }\n if (pluralForm) return `${number} ${number == 1 ? singleForm : pluralForm}`\n if (number != null) return patchedNpmPluralize(singleForm, number, true)\n return patchedNpmPluralize(singleForm)\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAEA,KAAC,SA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MAAM,4EAA4E,KAAK,UAAU,EAAE,GAAG,GAAG,WAAW,CAAC,CAAC,EAAE;AAAA,IACpI;AACA,iBAAa;AACb,aAAS;AAAA,EACX,WAAW,SAAS,CAAC,GAAG;AACtB,QAAI,CAAC,SAAS,CAAC,GAAG;AAChB,YAAM,IAAI,MAAM,4EAA4E,KAAK,UAAU,EAAE,GAAG,GAAG,WAAW,CAAC,CAAC,EAAE;AAAA,IACpI;AACA,iBAAa;AACb,aAAS;AAAA,EACX,OAAO;AACL,QAAI,CAAC,SAAS,CAAC,EAAG,OAAM,IAAI,MAAM,4EAA4E,KAAK,UAAU,EAAE,GAAG,GAAG,WAAW,CAAC,CAAC,EAAE;AACpJ,iBAAa;AACb,aAAS;AAAA,EACX;AACA,MAAI,WAAY,QAAO,GAAG,MAAM,IAAI,UAAU,IAAI,aAAa,UAAU;AACzE,MAAI,UAAU,KAAM,QAAO,oBAAoB,YAAY,QAAQ,IAAI;AACvE,SAAO,oBAAoB,UAAU;AACvC;","names":["pluralize","plural","npmPluralize"]}
package/package.json ADDED
@@ -0,0 +1,41 @@
1
+ {
2
+ "name": "@art-suite/art-core-ts-string-lib",
3
+ "version": "0.1.0",
4
+ "description": "A TypeScript string utility library",
5
+ "keywords": [],
6
+ "repository": {
7
+ "type": "git",
8
+ "url": "https://github.com/art-suite/art-suite-ts"
9
+ },
10
+ "license": "MIT",
11
+ "author": "Shane Delamore",
12
+ "type": "module",
13
+ "exports": {
14
+ ".": {
15
+ "types": "./dist/index.d.ts",
16
+ "import": "./dist/index.js",
17
+ "require": "./dist/index.cjs"
18
+ }
19
+ },
20
+ "main": "./dist/index.js",
21
+ "types": "./dist/index.d.ts",
22
+ "files": [
23
+ "dist"
24
+ ],
25
+ "scripts": {
26
+ "prebuild": "npm run clean",
27
+ "build": "npx sort-package-json;tsup src/index.ts --format esm,cjs --dts --sourcemap",
28
+ "build:clean": "npm run clean && npm run build",
29
+ "clean": "rm -rf dist",
30
+ "prepublishOnly": "npm run build",
31
+ "test": "vitest run",
32
+ "test:coverage": "vitest run --coverage",
33
+ "test:watch": "vitest"
34
+ },
35
+ "dependencies": {
36
+ "@art-suite/art-core-ts-types": "^0.1.4"
37
+ },
38
+ "devDependencies": {
39
+ "@vitest/coverage-v8": "^3.1.4"
40
+ }
41
+ }