@art-suite/art-core-ts-string-lib 0.3.0 → 1.0.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/dist/index.cjs +6 -419
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +2 -2
- package/dist/index.d.mts +2 -2
- package/dist/index.mjs +5 -443
- package/dist/index.mjs.map +1 -1
- package/package.json +3 -2
package/dist/index.cjs
CHANGED
|
@@ -6,7 +6,6 @@ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
|
6
6
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
7
7
|
var __getProtoOf = Object.getPrototypeOf;
|
|
8
8
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
9
|
-
var __commonJSMin = (cb, mod) => () => (mod || cb((mod = { exports: {} }).exports, mod), mod.exports);
|
|
10
9
|
var __copyProps = (to, from, except, desc) => {
|
|
11
10
|
if (from && typeof from === "object" || typeof from === "function") for (var keys = __getOwnPropNames(from), i = 0, n = keys.length, key; i < n; i++) {
|
|
12
11
|
key = keys[i];
|
|
@@ -22,6 +21,8 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
|
|
|
22
21
|
enumerable: true
|
|
23
22
|
}) : target, mod));
|
|
24
23
|
//#endregion
|
|
24
|
+
let pluralize_esm = require("pluralize-esm");
|
|
25
|
+
pluralize_esm = __toESM(pluralize_esm);
|
|
25
26
|
let _art_suite_art_core_ts_types = require("@art-suite/art-core-ts-types");
|
|
26
27
|
//#region src/commaize.ts
|
|
27
28
|
/**
|
|
@@ -32,429 +33,15 @@ let _art_suite_art_core_ts_types = require("@art-suite/art-core-ts-types");
|
|
|
32
33
|
const commaize = (x) => x.toString().replace(/\B(?=(\d{3})+(?!\d))/g, ",");
|
|
33
34
|
//#endregion
|
|
34
35
|
//#region src/pluralize.ts
|
|
35
|
-
var import_pluralize = /* @__PURE__ */ __toESM((/* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
36
|
-
(function(root, pluralize) {
|
|
37
|
-
/* istanbul ignore else */
|
|
38
|
-
if (typeof require === "function" && typeof exports === "object" && typeof module === "object") module.exports = pluralize();
|
|
39
|
-
else if (typeof define === "function" && define.amd) define(function() {
|
|
40
|
-
return pluralize();
|
|
41
|
-
});
|
|
42
|
-
else root.pluralize = pluralize();
|
|
43
|
-
})(exports, function() {
|
|
44
|
-
var pluralRules = [];
|
|
45
|
-
var singularRules = [];
|
|
46
|
-
var uncountables = {};
|
|
47
|
-
var irregularPlurals = {};
|
|
48
|
-
var irregularSingles = {};
|
|
49
|
-
/**
|
|
50
|
-
* Sanitize a pluralization rule to a usable regular expression.
|
|
51
|
-
*
|
|
52
|
-
* @param {(RegExp|string)} rule
|
|
53
|
-
* @return {RegExp}
|
|
54
|
-
*/
|
|
55
|
-
function sanitizeRule(rule) {
|
|
56
|
-
if (typeof rule === "string") return new RegExp("^" + rule + "$", "i");
|
|
57
|
-
return rule;
|
|
58
|
-
}
|
|
59
|
-
/**
|
|
60
|
-
* Pass in a word token to produce a function that can replicate the case on
|
|
61
|
-
* another word.
|
|
62
|
-
*
|
|
63
|
-
* @param {string} word
|
|
64
|
-
* @param {string} token
|
|
65
|
-
* @return {Function}
|
|
66
|
-
*/
|
|
67
|
-
function restoreCase(word, token) {
|
|
68
|
-
if (word === token) return token;
|
|
69
|
-
if (word === word.toLowerCase()) return token.toLowerCase();
|
|
70
|
-
if (word === word.toUpperCase()) return token.toUpperCase();
|
|
71
|
-
if (word[0] === word[0].toUpperCase()) return token.charAt(0).toUpperCase() + token.substr(1).toLowerCase();
|
|
72
|
-
return token.toLowerCase();
|
|
73
|
-
}
|
|
74
|
-
/**
|
|
75
|
-
* Interpolate a regexp string.
|
|
76
|
-
*
|
|
77
|
-
* @param {string} str
|
|
78
|
-
* @param {Array} args
|
|
79
|
-
* @return {string}
|
|
80
|
-
*/
|
|
81
|
-
function interpolate(str, args) {
|
|
82
|
-
return str.replace(/\$(\d{1,2})/g, function(match, index) {
|
|
83
|
-
return args[index] || "";
|
|
84
|
-
});
|
|
85
|
-
}
|
|
86
|
-
/**
|
|
87
|
-
* Replace a word using a rule.
|
|
88
|
-
*
|
|
89
|
-
* @param {string} word
|
|
90
|
-
* @param {Array} rule
|
|
91
|
-
* @return {string}
|
|
92
|
-
*/
|
|
93
|
-
function replace(word, rule) {
|
|
94
|
-
return word.replace(rule[0], function(match, index) {
|
|
95
|
-
var result = interpolate(rule[1], arguments);
|
|
96
|
-
if (match === "") return restoreCase(word[index - 1], result);
|
|
97
|
-
return restoreCase(match, result);
|
|
98
|
-
});
|
|
99
|
-
}
|
|
100
|
-
/**
|
|
101
|
-
* Sanitize a word by passing in the word and sanitization rules.
|
|
102
|
-
*
|
|
103
|
-
* @param {string} token
|
|
104
|
-
* @param {string} word
|
|
105
|
-
* @param {Array} rules
|
|
106
|
-
* @return {string}
|
|
107
|
-
*/
|
|
108
|
-
function sanitizeWord(token, word, rules) {
|
|
109
|
-
if (!token.length || uncountables.hasOwnProperty(token)) return word;
|
|
110
|
-
var len = rules.length;
|
|
111
|
-
while (len--) {
|
|
112
|
-
var rule = rules[len];
|
|
113
|
-
if (rule[0].test(word)) return replace(word, rule);
|
|
114
|
-
}
|
|
115
|
-
return word;
|
|
116
|
-
}
|
|
117
|
-
/**
|
|
118
|
-
* Replace a word with the updated word.
|
|
119
|
-
*
|
|
120
|
-
* @param {Object} replaceMap
|
|
121
|
-
* @param {Object} keepMap
|
|
122
|
-
* @param {Array} rules
|
|
123
|
-
* @return {Function}
|
|
124
|
-
*/
|
|
125
|
-
function replaceWord(replaceMap, keepMap, rules) {
|
|
126
|
-
return function(word) {
|
|
127
|
-
var token = word.toLowerCase();
|
|
128
|
-
if (keepMap.hasOwnProperty(token)) return restoreCase(word, token);
|
|
129
|
-
if (replaceMap.hasOwnProperty(token)) return restoreCase(word, replaceMap[token]);
|
|
130
|
-
return sanitizeWord(token, word, rules);
|
|
131
|
-
};
|
|
132
|
-
}
|
|
133
|
-
/**
|
|
134
|
-
* Check if a word is part of the map.
|
|
135
|
-
*/
|
|
136
|
-
function checkWord(replaceMap, keepMap, rules, bool) {
|
|
137
|
-
return function(word) {
|
|
138
|
-
var token = word.toLowerCase();
|
|
139
|
-
if (keepMap.hasOwnProperty(token)) return true;
|
|
140
|
-
if (replaceMap.hasOwnProperty(token)) return false;
|
|
141
|
-
return sanitizeWord(token, token, rules) === token;
|
|
142
|
-
};
|
|
143
|
-
}
|
|
144
|
-
/**
|
|
145
|
-
* Pluralize or singularize a word based on the passed in count.
|
|
146
|
-
*
|
|
147
|
-
* @param {string} word The word to pluralize
|
|
148
|
-
* @param {number} count How many of the word exist
|
|
149
|
-
* @param {boolean} inclusive Whether to prefix with the number (e.g. 3 ducks)
|
|
150
|
-
* @return {string}
|
|
151
|
-
*/
|
|
152
|
-
function pluralize(word, count, inclusive) {
|
|
153
|
-
var pluralized = count === 1 ? pluralize.singular(word) : pluralize.plural(word);
|
|
154
|
-
return (inclusive ? count + " " : "") + pluralized;
|
|
155
|
-
}
|
|
156
|
-
/**
|
|
157
|
-
* Pluralize a word.
|
|
158
|
-
*
|
|
159
|
-
* @type {Function}
|
|
160
|
-
*/
|
|
161
|
-
pluralize.plural = replaceWord(irregularSingles, irregularPlurals, pluralRules);
|
|
162
|
-
/**
|
|
163
|
-
* Check if a word is plural.
|
|
164
|
-
*
|
|
165
|
-
* @type {Function}
|
|
166
|
-
*/
|
|
167
|
-
pluralize.isPlural = checkWord(irregularSingles, irregularPlurals, pluralRules);
|
|
168
|
-
/**
|
|
169
|
-
* Singularize a word.
|
|
170
|
-
*
|
|
171
|
-
* @type {Function}
|
|
172
|
-
*/
|
|
173
|
-
pluralize.singular = replaceWord(irregularPlurals, irregularSingles, singularRules);
|
|
174
|
-
/**
|
|
175
|
-
* Check if a word is singular.
|
|
176
|
-
*
|
|
177
|
-
* @type {Function}
|
|
178
|
-
*/
|
|
179
|
-
pluralize.isSingular = checkWord(irregularPlurals, irregularSingles, singularRules);
|
|
180
|
-
/**
|
|
181
|
-
* Add a pluralization rule to the collection.
|
|
182
|
-
*
|
|
183
|
-
* @param {(string|RegExp)} rule
|
|
184
|
-
* @param {string} replacement
|
|
185
|
-
*/
|
|
186
|
-
pluralize.addPluralRule = function(rule, replacement) {
|
|
187
|
-
pluralRules.push([sanitizeRule(rule), replacement]);
|
|
188
|
-
};
|
|
189
|
-
/**
|
|
190
|
-
* Add a singularization rule to the collection.
|
|
191
|
-
*
|
|
192
|
-
* @param {(string|RegExp)} rule
|
|
193
|
-
* @param {string} replacement
|
|
194
|
-
*/
|
|
195
|
-
pluralize.addSingularRule = function(rule, replacement) {
|
|
196
|
-
singularRules.push([sanitizeRule(rule), replacement]);
|
|
197
|
-
};
|
|
198
|
-
/**
|
|
199
|
-
* Add an uncountable word rule.
|
|
200
|
-
*
|
|
201
|
-
* @param {(string|RegExp)} word
|
|
202
|
-
*/
|
|
203
|
-
pluralize.addUncountableRule = function(word) {
|
|
204
|
-
if (typeof word === "string") {
|
|
205
|
-
uncountables[word.toLowerCase()] = true;
|
|
206
|
-
return;
|
|
207
|
-
}
|
|
208
|
-
pluralize.addPluralRule(word, "$0");
|
|
209
|
-
pluralize.addSingularRule(word, "$0");
|
|
210
|
-
};
|
|
211
|
-
/**
|
|
212
|
-
* Add an irregular word definition.
|
|
213
|
-
*
|
|
214
|
-
* @param {string} single
|
|
215
|
-
* @param {string} plural
|
|
216
|
-
*/
|
|
217
|
-
pluralize.addIrregularRule = function(single, plural) {
|
|
218
|
-
plural = plural.toLowerCase();
|
|
219
|
-
single = single.toLowerCase();
|
|
220
|
-
irregularSingles[single] = plural;
|
|
221
|
-
irregularPlurals[plural] = single;
|
|
222
|
-
};
|
|
223
|
-
/**
|
|
224
|
-
* Irregular rules.
|
|
225
|
-
*/
|
|
226
|
-
[
|
|
227
|
-
["I", "we"],
|
|
228
|
-
["me", "us"],
|
|
229
|
-
["he", "they"],
|
|
230
|
-
["she", "they"],
|
|
231
|
-
["them", "them"],
|
|
232
|
-
["myself", "ourselves"],
|
|
233
|
-
["yourself", "yourselves"],
|
|
234
|
-
["itself", "themselves"],
|
|
235
|
-
["herself", "themselves"],
|
|
236
|
-
["himself", "themselves"],
|
|
237
|
-
["themself", "themselves"],
|
|
238
|
-
["is", "are"],
|
|
239
|
-
["was", "were"],
|
|
240
|
-
["has", "have"],
|
|
241
|
-
["this", "these"],
|
|
242
|
-
["that", "those"],
|
|
243
|
-
["echo", "echoes"],
|
|
244
|
-
["dingo", "dingoes"],
|
|
245
|
-
["volcano", "volcanoes"],
|
|
246
|
-
["tornado", "tornadoes"],
|
|
247
|
-
["torpedo", "torpedoes"],
|
|
248
|
-
["genus", "genera"],
|
|
249
|
-
["viscus", "viscera"],
|
|
250
|
-
["stigma", "stigmata"],
|
|
251
|
-
["stoma", "stomata"],
|
|
252
|
-
["dogma", "dogmata"],
|
|
253
|
-
["lemma", "lemmata"],
|
|
254
|
-
["schema", "schemata"],
|
|
255
|
-
["anathema", "anathemata"],
|
|
256
|
-
["ox", "oxen"],
|
|
257
|
-
["axe", "axes"],
|
|
258
|
-
["die", "dice"],
|
|
259
|
-
["yes", "yeses"],
|
|
260
|
-
["foot", "feet"],
|
|
261
|
-
["eave", "eaves"],
|
|
262
|
-
["goose", "geese"],
|
|
263
|
-
["tooth", "teeth"],
|
|
264
|
-
["quiz", "quizzes"],
|
|
265
|
-
["human", "humans"],
|
|
266
|
-
["proof", "proofs"],
|
|
267
|
-
["carve", "carves"],
|
|
268
|
-
["valve", "valves"],
|
|
269
|
-
["looey", "looies"],
|
|
270
|
-
["thief", "thieves"],
|
|
271
|
-
["groove", "grooves"],
|
|
272
|
-
["pickaxe", "pickaxes"],
|
|
273
|
-
["passerby", "passersby"]
|
|
274
|
-
].forEach(function(rule) {
|
|
275
|
-
return pluralize.addIrregularRule(rule[0], rule[1]);
|
|
276
|
-
});
|
|
277
|
-
/**
|
|
278
|
-
* Pluralization rules.
|
|
279
|
-
*/
|
|
280
|
-
[
|
|
281
|
-
[/s?$/i, "s"],
|
|
282
|
-
[/[^\u0000-\u007F]$/i, "$0"],
|
|
283
|
-
[/([^aeiou]ese)$/i, "$1"],
|
|
284
|
-
[/(ax|test)is$/i, "$1es"],
|
|
285
|
-
[/(alias|[^aou]us|t[lm]as|gas|ris)$/i, "$1es"],
|
|
286
|
-
[/(e[mn]u)s?$/i, "$1s"],
|
|
287
|
-
[/([^l]ias|[aeiou]las|[ejzr]as|[iu]am)$/i, "$1"],
|
|
288
|
-
[/(alumn|syllab|vir|radi|nucle|fung|cact|stimul|termin|bacill|foc|uter|loc|strat)(?:us|i)$/i, "$1i"],
|
|
289
|
-
[/(alumn|alg|vertebr)(?:a|ae)$/i, "$1ae"],
|
|
290
|
-
[/(seraph|cherub)(?:im)?$/i, "$1im"],
|
|
291
|
-
[/(her|at|gr)o$/i, "$1oes"],
|
|
292
|
-
[/(agend|addend|millenni|dat|extrem|bacteri|desiderat|strat|candelabr|errat|ov|symposi|curricul|automat|quor)(?:a|um)$/i, "$1a"],
|
|
293
|
-
[/(apheli|hyperbat|periheli|asyndet|noumen|phenomen|criteri|organ|prolegomen|hedr|automat)(?:a|on)$/i, "$1a"],
|
|
294
|
-
[/sis$/i, "ses"],
|
|
295
|
-
[/(?:(kni|wi|li)fe|(ar|l|ea|eo|oa|hoo)f)$/i, "$1$2ves"],
|
|
296
|
-
[/([^aeiouy]|qu)y$/i, "$1ies"],
|
|
297
|
-
[/([^ch][ieo][ln])ey$/i, "$1ies"],
|
|
298
|
-
[/(x|ch|ss|sh|zz)$/i, "$1es"],
|
|
299
|
-
[/(matr|cod|mur|sil|vert|ind|append)(?:ix|ex)$/i, "$1ices"],
|
|
300
|
-
[/\b((?:tit)?m|l)(?:ice|ouse)$/i, "$1ice"],
|
|
301
|
-
[/(pe)(?:rson|ople)$/i, "$1ople"],
|
|
302
|
-
[/(child)(?:ren)?$/i, "$1ren"],
|
|
303
|
-
[/eaux$/i, "$0"],
|
|
304
|
-
[/m[ae]n$/i, "men"],
|
|
305
|
-
["thou", "you"]
|
|
306
|
-
].forEach(function(rule) {
|
|
307
|
-
return pluralize.addPluralRule(rule[0], rule[1]);
|
|
308
|
-
});
|
|
309
|
-
/**
|
|
310
|
-
* Singularization rules.
|
|
311
|
-
*/
|
|
312
|
-
[
|
|
313
|
-
[/s$/i, ""],
|
|
314
|
-
[/(ss)$/i, "$1"],
|
|
315
|
-
[/(wi|kni|(?:after|half|high|low|mid|non|night|[^\w]|^)li)ves$/i, "$1fe"],
|
|
316
|
-
[/(ar|(?:wo|[ae])l|[eo][ao])ves$/i, "$1f"],
|
|
317
|
-
[/ies$/i, "y"],
|
|
318
|
-
[/\b([pl]|zomb|(?:neck|cross)?t|coll|faer|food|gen|goon|group|lass|talk|goal|cut)ies$/i, "$1ie"],
|
|
319
|
-
[/\b(mon|smil)ies$/i, "$1ey"],
|
|
320
|
-
[/\b((?:tit)?m|l)ice$/i, "$1ouse"],
|
|
321
|
-
[/(seraph|cherub)im$/i, "$1"],
|
|
322
|
-
[/(x|ch|ss|sh|zz|tto|go|cho|alias|[^aou]us|t[lm]as|gas|(?:her|at|gr)o|[aeiou]ris)(?:es)?$/i, "$1"],
|
|
323
|
-
[/(analy|diagno|parenthe|progno|synop|the|empha|cri|ne)(?:sis|ses)$/i, "$1sis"],
|
|
324
|
-
[/(movie|twelve|abuse|e[mn]u)s$/i, "$1"],
|
|
325
|
-
[/(test)(?:is|es)$/i, "$1is"],
|
|
326
|
-
[/(alumn|syllab|vir|radi|nucle|fung|cact|stimul|termin|bacill|foc|uter|loc|strat)(?:us|i)$/i, "$1us"],
|
|
327
|
-
[/(agend|addend|millenni|dat|extrem|bacteri|desiderat|strat|candelabr|errat|ov|symposi|curricul|quor)a$/i, "$1um"],
|
|
328
|
-
[/(apheli|hyperbat|periheli|asyndet|noumen|phenomen|criteri|organ|prolegomen|hedr|automat)a$/i, "$1on"],
|
|
329
|
-
[/(alumn|alg|vertebr)ae$/i, "$1a"],
|
|
330
|
-
[/(cod|mur|sil|vert|ind)ices$/i, "$1ex"],
|
|
331
|
-
[/(matr|append)ices$/i, "$1ix"],
|
|
332
|
-
[/(pe)(rson|ople)$/i, "$1rson"],
|
|
333
|
-
[/(child)ren$/i, "$1"],
|
|
334
|
-
[/(eau)x?$/i, "$1"],
|
|
335
|
-
[/men$/i, "man"]
|
|
336
|
-
].forEach(function(rule) {
|
|
337
|
-
return pluralize.addSingularRule(rule[0], rule[1]);
|
|
338
|
-
});
|
|
339
|
-
/**
|
|
340
|
-
* Uncountable rules.
|
|
341
|
-
*/
|
|
342
|
-
[
|
|
343
|
-
"adulthood",
|
|
344
|
-
"advice",
|
|
345
|
-
"agenda",
|
|
346
|
-
"aid",
|
|
347
|
-
"aircraft",
|
|
348
|
-
"alcohol",
|
|
349
|
-
"ammo",
|
|
350
|
-
"analytics",
|
|
351
|
-
"anime",
|
|
352
|
-
"athletics",
|
|
353
|
-
"audio",
|
|
354
|
-
"bison",
|
|
355
|
-
"blood",
|
|
356
|
-
"bream",
|
|
357
|
-
"buffalo",
|
|
358
|
-
"butter",
|
|
359
|
-
"carp",
|
|
360
|
-
"cash",
|
|
361
|
-
"chassis",
|
|
362
|
-
"chess",
|
|
363
|
-
"clothing",
|
|
364
|
-
"cod",
|
|
365
|
-
"commerce",
|
|
366
|
-
"cooperation",
|
|
367
|
-
"corps",
|
|
368
|
-
"debris",
|
|
369
|
-
"diabetes",
|
|
370
|
-
"digestion",
|
|
371
|
-
"elk",
|
|
372
|
-
"energy",
|
|
373
|
-
"equipment",
|
|
374
|
-
"excretion",
|
|
375
|
-
"expertise",
|
|
376
|
-
"firmware",
|
|
377
|
-
"flounder",
|
|
378
|
-
"fun",
|
|
379
|
-
"gallows",
|
|
380
|
-
"garbage",
|
|
381
|
-
"graffiti",
|
|
382
|
-
"hardware",
|
|
383
|
-
"headquarters",
|
|
384
|
-
"health",
|
|
385
|
-
"herpes",
|
|
386
|
-
"highjinks",
|
|
387
|
-
"homework",
|
|
388
|
-
"housework",
|
|
389
|
-
"information",
|
|
390
|
-
"jeans",
|
|
391
|
-
"justice",
|
|
392
|
-
"kudos",
|
|
393
|
-
"labour",
|
|
394
|
-
"literature",
|
|
395
|
-
"machinery",
|
|
396
|
-
"mackerel",
|
|
397
|
-
"mail",
|
|
398
|
-
"media",
|
|
399
|
-
"mews",
|
|
400
|
-
"moose",
|
|
401
|
-
"music",
|
|
402
|
-
"mud",
|
|
403
|
-
"manga",
|
|
404
|
-
"news",
|
|
405
|
-
"only",
|
|
406
|
-
"personnel",
|
|
407
|
-
"pike",
|
|
408
|
-
"plankton",
|
|
409
|
-
"pliers",
|
|
410
|
-
"police",
|
|
411
|
-
"pollution",
|
|
412
|
-
"premises",
|
|
413
|
-
"rain",
|
|
414
|
-
"research",
|
|
415
|
-
"rice",
|
|
416
|
-
"salmon",
|
|
417
|
-
"scissors",
|
|
418
|
-
"series",
|
|
419
|
-
"sewage",
|
|
420
|
-
"shambles",
|
|
421
|
-
"shrimp",
|
|
422
|
-
"software",
|
|
423
|
-
"species",
|
|
424
|
-
"staff",
|
|
425
|
-
"swine",
|
|
426
|
-
"tennis",
|
|
427
|
-
"traffic",
|
|
428
|
-
"transportation",
|
|
429
|
-
"trout",
|
|
430
|
-
"tuna",
|
|
431
|
-
"wealth",
|
|
432
|
-
"welfare",
|
|
433
|
-
"whiting",
|
|
434
|
-
"wildebeest",
|
|
435
|
-
"wildlife",
|
|
436
|
-
"you",
|
|
437
|
-
/pok[eé]mon$/i,
|
|
438
|
-
/[^aeiou]ese$/i,
|
|
439
|
-
/deer$/i,
|
|
440
|
-
/fish$/i,
|
|
441
|
-
/measles$/i,
|
|
442
|
-
/o[iu]s$/i,
|
|
443
|
-
/pox$/i,
|
|
444
|
-
/sheep$/i
|
|
445
|
-
].forEach(pluralize.addUncountableRule);
|
|
446
|
-
return pluralize;
|
|
447
|
-
});
|
|
448
|
-
})))(), 1);
|
|
449
36
|
const patchedNpmPluralize = (noun, count, inclusive) => {
|
|
450
37
|
const match = /^(.*?)([_\W]+)$/.exec(noun);
|
|
451
38
|
if (match) {
|
|
452
39
|
const [__, mainNoun, append] = match;
|
|
453
|
-
return (0,
|
|
40
|
+
return (0, pluralize_esm.default)(mainNoun, count, inclusive) + append;
|
|
454
41
|
}
|
|
455
|
-
return (0,
|
|
42
|
+
return (0, pluralize_esm.default)(noun, count, inclusive);
|
|
456
43
|
};
|
|
457
|
-
const { plural, singular, isSingular, isPlural, addPluralRule, addSingularRule, addIrregularRule, addUncountableRule } =
|
|
44
|
+
const { plural, singular, isSingular, isPlural, addPluralRule, addSingularRule, addIrregularRule, addUncountableRule } = pluralize_esm.default;
|
|
458
45
|
/**
|
|
459
46
|
* Pluralize a word based on the passed in count. Call signatures:
|
|
460
47
|
*
|
|
@@ -517,7 +104,7 @@ const intRand = (max) => {
|
|
|
517
104
|
* @param size Number of bytes to generate.
|
|
518
105
|
* @returns A Uint8Array filled with random bytes.
|
|
519
106
|
*/
|
|
520
|
-
const generateRandomBytes = (size) =>
|
|
107
|
+
const generateRandomBytes = (size) => crypto.getRandomValues(new Uint8Array(size));
|
|
521
108
|
const randomString = (length = 32, chars = base62Characters, randomNumbers) => {
|
|
522
109
|
const charsLength = chars.length;
|
|
523
110
|
let result = "";
|
package/dist/index.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.cjs","names":["npmPluralize"],"sources":["../src/commaize.ts","../../../node_modules/pluralize/pluralize.js","../src/pluralize.ts","../src/randomString.ts"],"sourcesContent":["/**\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","/* 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","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","export const base62Characters = \"0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ\"\n\nconst intRand = (max: number): number => {\n return Math.floor(Math.random() * max)\n}\n/**\n * Generates a Uint8Array of cryptographically secure random bytes.\n * @param size Number of bytes to generate.\n * @returns A Uint8Array filled with random bytes.\n */\nconst generateRandomBytes = (size: number): Uint8Array =>\n typeof crypto?.getRandomValues === 'function'\n ? crypto.getRandomValues(new Uint8Array(size))\n : require('crypto').randomFillSync(new Uint8Array(size));\n\n/*\n @randomString: randomString = (length = 32, chars = base62Characters, randomNumbers) ->\n result = ''\n charsLength = chars.length\n if randomNumbers\n (chars[randomNumbers[i] % charsLength] for i in [0...length] by 1).join ''\n else\n (chars[intRand charsLength] for i in [0...length] by 1).join ''\n*/\nexport const randomString = (length = 32, chars = base62Characters, randomNumbers?: Uint8Array | number[]): string => {\n const charsLength = chars.length\n let result = ''\n if (randomNumbers) {\n for (let i = 0; i < length; i++) result += chars[randomNumbers[i] % charsLength]\n } else {\n for (let i = 0; i < length; i++) result += chars[intRand(charsLength)]\n }\n return result\n}\n\nexport const cryptoRandomString = (length = 32, chars = base62Characters): string =>\n randomString(length, chars, generateRandomBytes(length).map(b => b % chars.length))"],"x_google_ignoreList":[1],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAKA,MAAa,YAAY,MAAuB,EAAE,UAAU,CAAC,QAAQ,yBAAyB,IAAI;;;;ACHlG,EAAC,SAAU,MAAM,WAAW;;AAE1B,MAAI,OAAO,YAAY,cAAc,OAAO,YAAY,YAAY,OAAO,WAAW,SAEpF,QAAO,UAAU,WAAW;WACnB,OAAO,WAAW,cAAc,OAAO,IAEhD,QAAO,WAAY;AACjB,UAAO,WAAW;IAClB;MAGF,MAAK,YAAY,WAAW;aAEvB,WAAY;EAGnB,IAAI,cAAc,EAAE;EACpB,IAAI,gBAAgB,EAAE;EACtB,IAAI,eAAe,EAAE;EACrB,IAAI,mBAAmB,EAAE;EACzB,IAAI,mBAAmB,EAAE;;;;;;;EAQzB,SAAS,aAAc,MAAM;AAC3B,OAAI,OAAO,SAAS,SAClB,QAAO,IA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AAqB,SAAS;GAC/B,CAAC,gBAAgB,KAAK;GACtB,CAAC,aAAa,KAAK;GACnB,CAAC,SAAS,MAAM;GACjB,CAAC,QAAQ,SAAU,MAAM;AACxB,UAAO,UAAU,gBAAgB,KAAK,IAAI,KAAK,GAAG;IAClD;;;;AAKF;GAEE;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GAEA;GACA;GACA;GACA;GACA;GACA;GACA;GACD,CAAC,QAAQ,UAAU,mBAAmB;AAEvC,SAAO;GACP;;ACnfF,MAAM,uBAAuB,MAAc,OAA4B,cAAoC;CACzG,MAAM,QAAQ,kBAAkB,KAAK,KAAK;AAC1C,KAAI,OAAO;EACT,MAAM,CAAC,IAAI,UAAU,UAAU;AAE/B,UAAA,GAAA,iBAAA,SADyB,UAAU,OAAO,UAAU,GACvC;;AAEf,SAAA,GAAA,iBAAA,SAAoB,MAAM,OAAO,UAAU;;AAG7C,MAAa,EACX,QACA,UACA,YACA,UACA,eACA,iBACA,kBACA,uBACEA,iBAAAA;;;;;;;;;;;;;;;;;;;;AAqBJ,MAAa,aAAa,GAAoB,GAAqB,eAAwB;CACzF,IAAI;CACJ,IAAI,SAAwB;AAC5B,MAAA,GAAA,6BAAA,UAAa,EAAE,EAAE;AACf,MAAI,EAAA,GAAA,6BAAA,UAAU,EAAE,CACd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+
{"version":3,"file":"index.cjs","names":["npmPluralize"],"sources":["../src/commaize.ts","../src/pluralize.ts","../src/randomString.ts"],"sourcesContent":["/**\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-esm'\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","export const base62Characters = \"0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ\"\n\nconst intRand = (max: number): number => {\n return Math.floor(Math.random() * max)\n}\n/**\n * Generates a Uint8Array of cryptographically secure random bytes.\n * @param size Number of bytes to generate.\n * @returns A Uint8Array filled with random bytes.\n */\nconst generateRandomBytes = (size: number): Uint8Array =>\n crypto.getRandomValues(new Uint8Array(size))\n\n/*\n @randomString: randomString = (length = 32, chars = base62Characters, randomNumbers) ->\n result = ''\n charsLength = chars.length\n if randomNumbers\n (chars[randomNumbers[i] % charsLength] for i in [0...length] by 1).join ''\n else\n (chars[intRand charsLength] for i in [0...length] by 1).join ''\n*/\nexport const randomString = (length = 32, chars = base62Characters, randomNumbers?: Uint8Array | number[]): string => {\n const charsLength = chars.length\n let result = ''\n if (randomNumbers) {\n for (let i = 0; i < length; i++) result += chars[randomNumbers[i] % charsLength]\n } else {\n for (let i = 0; i < length; i++) result += chars[intRand(charsLength)]\n }\n return result\n}\n\nexport const cryptoRandomString = (length = 32, chars = base62Characters): string =>\n randomString(length, chars, generateRandomBytes(length).map(b => b % chars.length))"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAKA,MAAa,YAAY,MAAuB,EAAE,UAAU,CAAC,QAAQ,yBAAyB,IAAI;;;ACFlG,MAAM,uBAAuB,MAAc,OAA4B,cAAoC;CACzG,MAAM,QAAQ,kBAAkB,KAAK,KAAK;AAC1C,KAAI,OAAO;EACT,MAAM,CAAC,IAAI,UAAU,UAAU;AAE/B,UAAA,GAAA,cAAA,SADyB,UAAU,OAAO,UAAU,GACvC;;AAEf,SAAA,GAAA,cAAA,SA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IAAI,QAAQ,IAAK,WAAU,MAAM,QAAQ,YAAY;AAEvE,QAAO;;AAGT,MAAa,sBAAsB,SAAS,IAAI,QAAQ,qBACtD,aAAa,QAAQ,OAAO,oBAAoB,OAAO,CAAC,KAAI,MAAK,IAAI,MAAM,OAAO,CAAA"}
|
package/dist/index.d.cts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import
|
|
1
|
+
import * as _$pluralize_esm0 from "pluralize-esm";
|
|
2
2
|
|
|
3
3
|
//#region src/commaize.d.ts
|
|
4
4
|
/**
|
|
@@ -9,7 +9,7 @@ import npmPluralize from "pluralize";
|
|
|
9
9
|
declare const commaize: (x: number | string) => string;
|
|
10
10
|
//#endregion
|
|
11
11
|
//#region src/pluralize.d.ts
|
|
12
|
-
declare const plural:
|
|
12
|
+
declare const plural: (word: string) => string, singular: (word: string) => string, isSingular: (word: string) => boolean, isPlural: (word: string) => boolean, addPluralRule: (rule: _$pluralize_esm0.Rule, replacement: string) => void, addSingularRule: (rule: _$pluralize_esm0.Rule, replacement: string) => void, addIrregularRule: (single: string, plural: string) => void, addUncountableRule: (rule: _$pluralize_esm0.Rule) => void;
|
|
13
13
|
/**
|
|
14
14
|
* Pluralize a word based on the passed in count. Call signatures:
|
|
15
15
|
*
|
package/dist/index.d.mts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import
|
|
1
|
+
import * as _$pluralize_esm0 from "pluralize-esm";
|
|
2
2
|
|
|
3
3
|
//#region src/commaize.d.ts
|
|
4
4
|
/**
|
|
@@ -9,7 +9,7 @@ import npmPluralize from "pluralize";
|
|
|
9
9
|
declare const commaize: (x: number | string) => string;
|
|
10
10
|
//#endregion
|
|
11
11
|
//#region src/pluralize.d.ts
|
|
12
|
-
declare const plural:
|
|
12
|
+
declare const plural: (word: string) => string, singular: (word: string) => string, isSingular: (word: string) => boolean, isPlural: (word: string) => boolean, addPluralRule: (rule: _$pluralize_esm0.Rule, replacement: string) => void, addSingularRule: (rule: _$pluralize_esm0.Rule, replacement: string) => void, addIrregularRule: (single: string, plural: string) => void, addUncountableRule: (rule: _$pluralize_esm0.Rule) => void;
|
|
13
13
|
/**
|
|
14
14
|
* Pluralize a word based on the passed in count. Call signatures:
|
|
15
15
|
*
|
package/dist/index.mjs
CHANGED
|
@@ -1,29 +1,5 @@
|
|
|
1
|
-
import
|
|
1
|
+
import npmPluralize from "pluralize-esm";
|
|
2
2
|
import { isNumber, isString } from "@art-suite/art-core-ts-types";
|
|
3
|
-
//#region \0rolldown/runtime.js
|
|
4
|
-
var __create = Object.create;
|
|
5
|
-
var __defProp = Object.defineProperty;
|
|
6
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
7
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
8
|
-
var __getProtoOf = Object.getPrototypeOf;
|
|
9
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
10
|
-
var __commonJSMin = (cb, mod) => () => (mod || cb((mod = { exports: {} }).exports, mod), mod.exports);
|
|
11
|
-
var __copyProps = (to, from, except, desc) => {
|
|
12
|
-
if (from && typeof from === "object" || typeof from === "function") for (var keys = __getOwnPropNames(from), i = 0, n = keys.length, key; i < n; i++) {
|
|
13
|
-
key = keys[i];
|
|
14
|
-
if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
|
|
15
|
-
get: ((k) => from[k]).bind(null, key),
|
|
16
|
-
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
|
17
|
-
});
|
|
18
|
-
}
|
|
19
|
-
return to;
|
|
20
|
-
};
|
|
21
|
-
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
|
|
22
|
-
value: mod,
|
|
23
|
-
enumerable: true
|
|
24
|
-
}) : target, mod));
|
|
25
|
-
var __require = /* @__PURE__ */ createRequire(import.meta.url);
|
|
26
|
-
//#endregion
|
|
27
3
|
//#region src/commaize.ts
|
|
28
4
|
/**
|
|
29
5
|
* Adds commas to a number or string
|
|
@@ -33,429 +9,15 @@ var __require = /* @__PURE__ */ createRequire(import.meta.url);
|
|
|
33
9
|
const commaize = (x) => x.toString().replace(/\B(?=(\d{3})+(?!\d))/g, ",");
|
|
34
10
|
//#endregion
|
|
35
11
|
//#region src/pluralize.ts
|
|
36
|
-
var import_pluralize = /* @__PURE__ */ __toESM((/* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
37
|
-
(function(root, pluralize) {
|
|
38
|
-
/* istanbul ignore else */
|
|
39
|
-
if (typeof __require === "function" && typeof exports === "object" && typeof module === "object") module.exports = pluralize();
|
|
40
|
-
else if (typeof define === "function" && define.amd) define(function() {
|
|
41
|
-
return pluralize();
|
|
42
|
-
});
|
|
43
|
-
else root.pluralize = pluralize();
|
|
44
|
-
})(exports, function() {
|
|
45
|
-
var pluralRules = [];
|
|
46
|
-
var singularRules = [];
|
|
47
|
-
var uncountables = {};
|
|
48
|
-
var irregularPlurals = {};
|
|
49
|
-
var irregularSingles = {};
|
|
50
|
-
/**
|
|
51
|
-
* Sanitize a pluralization rule to a usable regular expression.
|
|
52
|
-
*
|
|
53
|
-
* @param {(RegExp|string)} rule
|
|
54
|
-
* @return {RegExp}
|
|
55
|
-
*/
|
|
56
|
-
function sanitizeRule(rule) {
|
|
57
|
-
if (typeof rule === "string") return new RegExp("^" + rule + "$", "i");
|
|
58
|
-
return rule;
|
|
59
|
-
}
|
|
60
|
-
/**
|
|
61
|
-
* Pass in a word token to produce a function that can replicate the case on
|
|
62
|
-
* another word.
|
|
63
|
-
*
|
|
64
|
-
* @param {string} word
|
|
65
|
-
* @param {string} token
|
|
66
|
-
* @return {Function}
|
|
67
|
-
*/
|
|
68
|
-
function restoreCase(word, token) {
|
|
69
|
-
if (word === token) return token;
|
|
70
|
-
if (word === word.toLowerCase()) return token.toLowerCase();
|
|
71
|
-
if (word === word.toUpperCase()) return token.toUpperCase();
|
|
72
|
-
if (word[0] === word[0].toUpperCase()) return token.charAt(0).toUpperCase() + token.substr(1).toLowerCase();
|
|
73
|
-
return token.toLowerCase();
|
|
74
|
-
}
|
|
75
|
-
/**
|
|
76
|
-
* Interpolate a regexp string.
|
|
77
|
-
*
|
|
78
|
-
* @param {string} str
|
|
79
|
-
* @param {Array} args
|
|
80
|
-
* @return {string}
|
|
81
|
-
*/
|
|
82
|
-
function interpolate(str, args) {
|
|
83
|
-
return str.replace(/\$(\d{1,2})/g, function(match, index) {
|
|
84
|
-
return args[index] || "";
|
|
85
|
-
});
|
|
86
|
-
}
|
|
87
|
-
/**
|
|
88
|
-
* Replace a word using a rule.
|
|
89
|
-
*
|
|
90
|
-
* @param {string} word
|
|
91
|
-
* @param {Array} rule
|
|
92
|
-
* @return {string}
|
|
93
|
-
*/
|
|
94
|
-
function replace(word, rule) {
|
|
95
|
-
return word.replace(rule[0], function(match, index) {
|
|
96
|
-
var result = interpolate(rule[1], arguments);
|
|
97
|
-
if (match === "") return restoreCase(word[index - 1], result);
|
|
98
|
-
return restoreCase(match, result);
|
|
99
|
-
});
|
|
100
|
-
}
|
|
101
|
-
/**
|
|
102
|
-
* Sanitize a word by passing in the word and sanitization rules.
|
|
103
|
-
*
|
|
104
|
-
* @param {string} token
|
|
105
|
-
* @param {string} word
|
|
106
|
-
* @param {Array} rules
|
|
107
|
-
* @return {string}
|
|
108
|
-
*/
|
|
109
|
-
function sanitizeWord(token, word, rules) {
|
|
110
|
-
if (!token.length || uncountables.hasOwnProperty(token)) return word;
|
|
111
|
-
var len = rules.length;
|
|
112
|
-
while (len--) {
|
|
113
|
-
var rule = rules[len];
|
|
114
|
-
if (rule[0].test(word)) return replace(word, rule);
|
|
115
|
-
}
|
|
116
|
-
return word;
|
|
117
|
-
}
|
|
118
|
-
/**
|
|
119
|
-
* Replace a word with the updated word.
|
|
120
|
-
*
|
|
121
|
-
* @param {Object} replaceMap
|
|
122
|
-
* @param {Object} keepMap
|
|
123
|
-
* @param {Array} rules
|
|
124
|
-
* @return {Function}
|
|
125
|
-
*/
|
|
126
|
-
function replaceWord(replaceMap, keepMap, rules) {
|
|
127
|
-
return function(word) {
|
|
128
|
-
var token = word.toLowerCase();
|
|
129
|
-
if (keepMap.hasOwnProperty(token)) return restoreCase(word, token);
|
|
130
|
-
if (replaceMap.hasOwnProperty(token)) return restoreCase(word, replaceMap[token]);
|
|
131
|
-
return sanitizeWord(token, word, rules);
|
|
132
|
-
};
|
|
133
|
-
}
|
|
134
|
-
/**
|
|
135
|
-
* Check if a word is part of the map.
|
|
136
|
-
*/
|
|
137
|
-
function checkWord(replaceMap, keepMap, rules, bool) {
|
|
138
|
-
return function(word) {
|
|
139
|
-
var token = word.toLowerCase();
|
|
140
|
-
if (keepMap.hasOwnProperty(token)) return true;
|
|
141
|
-
if (replaceMap.hasOwnProperty(token)) return false;
|
|
142
|
-
return sanitizeWord(token, token, rules) === token;
|
|
143
|
-
};
|
|
144
|
-
}
|
|
145
|
-
/**
|
|
146
|
-
* Pluralize or singularize a word based on the passed in count.
|
|
147
|
-
*
|
|
148
|
-
* @param {string} word The word to pluralize
|
|
149
|
-
* @param {number} count How many of the word exist
|
|
150
|
-
* @param {boolean} inclusive Whether to prefix with the number (e.g. 3 ducks)
|
|
151
|
-
* @return {string}
|
|
152
|
-
*/
|
|
153
|
-
function pluralize(word, count, inclusive) {
|
|
154
|
-
var pluralized = count === 1 ? pluralize.singular(word) : pluralize.plural(word);
|
|
155
|
-
return (inclusive ? count + " " : "") + pluralized;
|
|
156
|
-
}
|
|
157
|
-
/**
|
|
158
|
-
* Pluralize a word.
|
|
159
|
-
*
|
|
160
|
-
* @type {Function}
|
|
161
|
-
*/
|
|
162
|
-
pluralize.plural = replaceWord(irregularSingles, irregularPlurals, pluralRules);
|
|
163
|
-
/**
|
|
164
|
-
* Check if a word is plural.
|
|
165
|
-
*
|
|
166
|
-
* @type {Function}
|
|
167
|
-
*/
|
|
168
|
-
pluralize.isPlural = checkWord(irregularSingles, irregularPlurals, pluralRules);
|
|
169
|
-
/**
|
|
170
|
-
* Singularize a word.
|
|
171
|
-
*
|
|
172
|
-
* @type {Function}
|
|
173
|
-
*/
|
|
174
|
-
pluralize.singular = replaceWord(irregularPlurals, irregularSingles, singularRules);
|
|
175
|
-
/**
|
|
176
|
-
* Check if a word is singular.
|
|
177
|
-
*
|
|
178
|
-
* @type {Function}
|
|
179
|
-
*/
|
|
180
|
-
pluralize.isSingular = checkWord(irregularPlurals, irregularSingles, singularRules);
|
|
181
|
-
/**
|
|
182
|
-
* Add a pluralization rule to the collection.
|
|
183
|
-
*
|
|
184
|
-
* @param {(string|RegExp)} rule
|
|
185
|
-
* @param {string} replacement
|
|
186
|
-
*/
|
|
187
|
-
pluralize.addPluralRule = function(rule, replacement) {
|
|
188
|
-
pluralRules.push([sanitizeRule(rule), replacement]);
|
|
189
|
-
};
|
|
190
|
-
/**
|
|
191
|
-
* Add a singularization rule to the collection.
|
|
192
|
-
*
|
|
193
|
-
* @param {(string|RegExp)} rule
|
|
194
|
-
* @param {string} replacement
|
|
195
|
-
*/
|
|
196
|
-
pluralize.addSingularRule = function(rule, replacement) {
|
|
197
|
-
singularRules.push([sanitizeRule(rule), replacement]);
|
|
198
|
-
};
|
|
199
|
-
/**
|
|
200
|
-
* Add an uncountable word rule.
|
|
201
|
-
*
|
|
202
|
-
* @param {(string|RegExp)} word
|
|
203
|
-
*/
|
|
204
|
-
pluralize.addUncountableRule = function(word) {
|
|
205
|
-
if (typeof word === "string") {
|
|
206
|
-
uncountables[word.toLowerCase()] = true;
|
|
207
|
-
return;
|
|
208
|
-
}
|
|
209
|
-
pluralize.addPluralRule(word, "$0");
|
|
210
|
-
pluralize.addSingularRule(word, "$0");
|
|
211
|
-
};
|
|
212
|
-
/**
|
|
213
|
-
* Add an irregular word definition.
|
|
214
|
-
*
|
|
215
|
-
* @param {string} single
|
|
216
|
-
* @param {string} plural
|
|
217
|
-
*/
|
|
218
|
-
pluralize.addIrregularRule = function(single, plural) {
|
|
219
|
-
plural = plural.toLowerCase();
|
|
220
|
-
single = single.toLowerCase();
|
|
221
|
-
irregularSingles[single] = plural;
|
|
222
|
-
irregularPlurals[plural] = single;
|
|
223
|
-
};
|
|
224
|
-
/**
|
|
225
|
-
* Irregular rules.
|
|
226
|
-
*/
|
|
227
|
-
[
|
|
228
|
-
["I", "we"],
|
|
229
|
-
["me", "us"],
|
|
230
|
-
["he", "they"],
|
|
231
|
-
["she", "they"],
|
|
232
|
-
["them", "them"],
|
|
233
|
-
["myself", "ourselves"],
|
|
234
|
-
["yourself", "yourselves"],
|
|
235
|
-
["itself", "themselves"],
|
|
236
|
-
["herself", "themselves"],
|
|
237
|
-
["himself", "themselves"],
|
|
238
|
-
["themself", "themselves"],
|
|
239
|
-
["is", "are"],
|
|
240
|
-
["was", "were"],
|
|
241
|
-
["has", "have"],
|
|
242
|
-
["this", "these"],
|
|
243
|
-
["that", "those"],
|
|
244
|
-
["echo", "echoes"],
|
|
245
|
-
["dingo", "dingoes"],
|
|
246
|
-
["volcano", "volcanoes"],
|
|
247
|
-
["tornado", "tornadoes"],
|
|
248
|
-
["torpedo", "torpedoes"],
|
|
249
|
-
["genus", "genera"],
|
|
250
|
-
["viscus", "viscera"],
|
|
251
|
-
["stigma", "stigmata"],
|
|
252
|
-
["stoma", "stomata"],
|
|
253
|
-
["dogma", "dogmata"],
|
|
254
|
-
["lemma", "lemmata"],
|
|
255
|
-
["schema", "schemata"],
|
|
256
|
-
["anathema", "anathemata"],
|
|
257
|
-
["ox", "oxen"],
|
|
258
|
-
["axe", "axes"],
|
|
259
|
-
["die", "dice"],
|
|
260
|
-
["yes", "yeses"],
|
|
261
|
-
["foot", "feet"],
|
|
262
|
-
["eave", "eaves"],
|
|
263
|
-
["goose", "geese"],
|
|
264
|
-
["tooth", "teeth"],
|
|
265
|
-
["quiz", "quizzes"],
|
|
266
|
-
["human", "humans"],
|
|
267
|
-
["proof", "proofs"],
|
|
268
|
-
["carve", "carves"],
|
|
269
|
-
["valve", "valves"],
|
|
270
|
-
["looey", "looies"],
|
|
271
|
-
["thief", "thieves"],
|
|
272
|
-
["groove", "grooves"],
|
|
273
|
-
["pickaxe", "pickaxes"],
|
|
274
|
-
["passerby", "passersby"]
|
|
275
|
-
].forEach(function(rule) {
|
|
276
|
-
return pluralize.addIrregularRule(rule[0], rule[1]);
|
|
277
|
-
});
|
|
278
|
-
/**
|
|
279
|
-
* Pluralization rules.
|
|
280
|
-
*/
|
|
281
|
-
[
|
|
282
|
-
[/s?$/i, "s"],
|
|
283
|
-
[/[^\u0000-\u007F]$/i, "$0"],
|
|
284
|
-
[/([^aeiou]ese)$/i, "$1"],
|
|
285
|
-
[/(ax|test)is$/i, "$1es"],
|
|
286
|
-
[/(alias|[^aou]us|t[lm]as|gas|ris)$/i, "$1es"],
|
|
287
|
-
[/(e[mn]u)s?$/i, "$1s"],
|
|
288
|
-
[/([^l]ias|[aeiou]las|[ejzr]as|[iu]am)$/i, "$1"],
|
|
289
|
-
[/(alumn|syllab|vir|radi|nucle|fung|cact|stimul|termin|bacill|foc|uter|loc|strat)(?:us|i)$/i, "$1i"],
|
|
290
|
-
[/(alumn|alg|vertebr)(?:a|ae)$/i, "$1ae"],
|
|
291
|
-
[/(seraph|cherub)(?:im)?$/i, "$1im"],
|
|
292
|
-
[/(her|at|gr)o$/i, "$1oes"],
|
|
293
|
-
[/(agend|addend|millenni|dat|extrem|bacteri|desiderat|strat|candelabr|errat|ov|symposi|curricul|automat|quor)(?:a|um)$/i, "$1a"],
|
|
294
|
-
[/(apheli|hyperbat|periheli|asyndet|noumen|phenomen|criteri|organ|prolegomen|hedr|automat)(?:a|on)$/i, "$1a"],
|
|
295
|
-
[/sis$/i, "ses"],
|
|
296
|
-
[/(?:(kni|wi|li)fe|(ar|l|ea|eo|oa|hoo)f)$/i, "$1$2ves"],
|
|
297
|
-
[/([^aeiouy]|qu)y$/i, "$1ies"],
|
|
298
|
-
[/([^ch][ieo][ln])ey$/i, "$1ies"],
|
|
299
|
-
[/(x|ch|ss|sh|zz)$/i, "$1es"],
|
|
300
|
-
[/(matr|cod|mur|sil|vert|ind|append)(?:ix|ex)$/i, "$1ices"],
|
|
301
|
-
[/\b((?:tit)?m|l)(?:ice|ouse)$/i, "$1ice"],
|
|
302
|
-
[/(pe)(?:rson|ople)$/i, "$1ople"],
|
|
303
|
-
[/(child)(?:ren)?$/i, "$1ren"],
|
|
304
|
-
[/eaux$/i, "$0"],
|
|
305
|
-
[/m[ae]n$/i, "men"],
|
|
306
|
-
["thou", "you"]
|
|
307
|
-
].forEach(function(rule) {
|
|
308
|
-
return pluralize.addPluralRule(rule[0], rule[1]);
|
|
309
|
-
});
|
|
310
|
-
/**
|
|
311
|
-
* Singularization rules.
|
|
312
|
-
*/
|
|
313
|
-
[
|
|
314
|
-
[/s$/i, ""],
|
|
315
|
-
[/(ss)$/i, "$1"],
|
|
316
|
-
[/(wi|kni|(?:after|half|high|low|mid|non|night|[^\w]|^)li)ves$/i, "$1fe"],
|
|
317
|
-
[/(ar|(?:wo|[ae])l|[eo][ao])ves$/i, "$1f"],
|
|
318
|
-
[/ies$/i, "y"],
|
|
319
|
-
[/\b([pl]|zomb|(?:neck|cross)?t|coll|faer|food|gen|goon|group|lass|talk|goal|cut)ies$/i, "$1ie"],
|
|
320
|
-
[/\b(mon|smil)ies$/i, "$1ey"],
|
|
321
|
-
[/\b((?:tit)?m|l)ice$/i, "$1ouse"],
|
|
322
|
-
[/(seraph|cherub)im$/i, "$1"],
|
|
323
|
-
[/(x|ch|ss|sh|zz|tto|go|cho|alias|[^aou]us|t[lm]as|gas|(?:her|at|gr)o|[aeiou]ris)(?:es)?$/i, "$1"],
|
|
324
|
-
[/(analy|diagno|parenthe|progno|synop|the|empha|cri|ne)(?:sis|ses)$/i, "$1sis"],
|
|
325
|
-
[/(movie|twelve|abuse|e[mn]u)s$/i, "$1"],
|
|
326
|
-
[/(test)(?:is|es)$/i, "$1is"],
|
|
327
|
-
[/(alumn|syllab|vir|radi|nucle|fung|cact|stimul|termin|bacill|foc|uter|loc|strat)(?:us|i)$/i, "$1us"],
|
|
328
|
-
[/(agend|addend|millenni|dat|extrem|bacteri|desiderat|strat|candelabr|errat|ov|symposi|curricul|quor)a$/i, "$1um"],
|
|
329
|
-
[/(apheli|hyperbat|periheli|asyndet|noumen|phenomen|criteri|organ|prolegomen|hedr|automat)a$/i, "$1on"],
|
|
330
|
-
[/(alumn|alg|vertebr)ae$/i, "$1a"],
|
|
331
|
-
[/(cod|mur|sil|vert|ind)ices$/i, "$1ex"],
|
|
332
|
-
[/(matr|append)ices$/i, "$1ix"],
|
|
333
|
-
[/(pe)(rson|ople)$/i, "$1rson"],
|
|
334
|
-
[/(child)ren$/i, "$1"],
|
|
335
|
-
[/(eau)x?$/i, "$1"],
|
|
336
|
-
[/men$/i, "man"]
|
|
337
|
-
].forEach(function(rule) {
|
|
338
|
-
return pluralize.addSingularRule(rule[0], rule[1]);
|
|
339
|
-
});
|
|
340
|
-
/**
|
|
341
|
-
* Uncountable rules.
|
|
342
|
-
*/
|
|
343
|
-
[
|
|
344
|
-
"adulthood",
|
|
345
|
-
"advice",
|
|
346
|
-
"agenda",
|
|
347
|
-
"aid",
|
|
348
|
-
"aircraft",
|
|
349
|
-
"alcohol",
|
|
350
|
-
"ammo",
|
|
351
|
-
"analytics",
|
|
352
|
-
"anime",
|
|
353
|
-
"athletics",
|
|
354
|
-
"audio",
|
|
355
|
-
"bison",
|
|
356
|
-
"blood",
|
|
357
|
-
"bream",
|
|
358
|
-
"buffalo",
|
|
359
|
-
"butter",
|
|
360
|
-
"carp",
|
|
361
|
-
"cash",
|
|
362
|
-
"chassis",
|
|
363
|
-
"chess",
|
|
364
|
-
"clothing",
|
|
365
|
-
"cod",
|
|
366
|
-
"commerce",
|
|
367
|
-
"cooperation",
|
|
368
|
-
"corps",
|
|
369
|
-
"debris",
|
|
370
|
-
"diabetes",
|
|
371
|
-
"digestion",
|
|
372
|
-
"elk",
|
|
373
|
-
"energy",
|
|
374
|
-
"equipment",
|
|
375
|
-
"excretion",
|
|
376
|
-
"expertise",
|
|
377
|
-
"firmware",
|
|
378
|
-
"flounder",
|
|
379
|
-
"fun",
|
|
380
|
-
"gallows",
|
|
381
|
-
"garbage",
|
|
382
|
-
"graffiti",
|
|
383
|
-
"hardware",
|
|
384
|
-
"headquarters",
|
|
385
|
-
"health",
|
|
386
|
-
"herpes",
|
|
387
|
-
"highjinks",
|
|
388
|
-
"homework",
|
|
389
|
-
"housework",
|
|
390
|
-
"information",
|
|
391
|
-
"jeans",
|
|
392
|
-
"justice",
|
|
393
|
-
"kudos",
|
|
394
|
-
"labour",
|
|
395
|
-
"literature",
|
|
396
|
-
"machinery",
|
|
397
|
-
"mackerel",
|
|
398
|
-
"mail",
|
|
399
|
-
"media",
|
|
400
|
-
"mews",
|
|
401
|
-
"moose",
|
|
402
|
-
"music",
|
|
403
|
-
"mud",
|
|
404
|
-
"manga",
|
|
405
|
-
"news",
|
|
406
|
-
"only",
|
|
407
|
-
"personnel",
|
|
408
|
-
"pike",
|
|
409
|
-
"plankton",
|
|
410
|
-
"pliers",
|
|
411
|
-
"police",
|
|
412
|
-
"pollution",
|
|
413
|
-
"premises",
|
|
414
|
-
"rain",
|
|
415
|
-
"research",
|
|
416
|
-
"rice",
|
|
417
|
-
"salmon",
|
|
418
|
-
"scissors",
|
|
419
|
-
"series",
|
|
420
|
-
"sewage",
|
|
421
|
-
"shambles",
|
|
422
|
-
"shrimp",
|
|
423
|
-
"software",
|
|
424
|
-
"species",
|
|
425
|
-
"staff",
|
|
426
|
-
"swine",
|
|
427
|
-
"tennis",
|
|
428
|
-
"traffic",
|
|
429
|
-
"transportation",
|
|
430
|
-
"trout",
|
|
431
|
-
"tuna",
|
|
432
|
-
"wealth",
|
|
433
|
-
"welfare",
|
|
434
|
-
"whiting",
|
|
435
|
-
"wildebeest",
|
|
436
|
-
"wildlife",
|
|
437
|
-
"you",
|
|
438
|
-
/pok[eé]mon$/i,
|
|
439
|
-
/[^aeiou]ese$/i,
|
|
440
|
-
/deer$/i,
|
|
441
|
-
/fish$/i,
|
|
442
|
-
/measles$/i,
|
|
443
|
-
/o[iu]s$/i,
|
|
444
|
-
/pox$/i,
|
|
445
|
-
/sheep$/i
|
|
446
|
-
].forEach(pluralize.addUncountableRule);
|
|
447
|
-
return pluralize;
|
|
448
|
-
});
|
|
449
|
-
})))(), 1);
|
|
450
12
|
const patchedNpmPluralize = (noun, count, inclusive) => {
|
|
451
13
|
const match = /^(.*?)([_\W]+)$/.exec(noun);
|
|
452
14
|
if (match) {
|
|
453
15
|
const [__, mainNoun, append] = match;
|
|
454
|
-
return (
|
|
16
|
+
return npmPluralize(mainNoun, count, inclusive) + append;
|
|
455
17
|
}
|
|
456
|
-
return (
|
|
18
|
+
return npmPluralize(noun, count, inclusive);
|
|
457
19
|
};
|
|
458
|
-
const { plural, singular, isSingular, isPlural, addPluralRule, addSingularRule, addIrregularRule, addUncountableRule } =
|
|
20
|
+
const { plural, singular, isSingular, isPlural, addPluralRule, addSingularRule, addIrregularRule, addUncountableRule } = npmPluralize;
|
|
459
21
|
/**
|
|
460
22
|
* Pluralize a word based on the passed in count. Call signatures:
|
|
461
23
|
*
|
|
@@ -518,7 +80,7 @@ const intRand = (max) => {
|
|
|
518
80
|
* @param size Number of bytes to generate.
|
|
519
81
|
* @returns A Uint8Array filled with random bytes.
|
|
520
82
|
*/
|
|
521
|
-
const generateRandomBytes = (size) =>
|
|
83
|
+
const generateRandomBytes = (size) => crypto.getRandomValues(new Uint8Array(size));
|
|
522
84
|
const randomString = (length = 32, chars = base62Characters, randomNumbers) => {
|
|
523
85
|
const charsLength = chars.length;
|
|
524
86
|
let result = "";
|
package/dist/index.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.mjs","names":["npmPluralize"],"sources":["../src/commaize.ts","../../../node_modules/pluralize/pluralize.js","../src/pluralize.ts","../src/randomString.ts"],"sourcesContent":["/**\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","/* 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","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","export const base62Characters = \"0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ\"\n\nconst intRand = (max: number): number => {\n return Math.floor(Math.random() * max)\n}\n/**\n * Generates a Uint8Array of cryptographically secure random bytes.\n * @param size Number of bytes to generate.\n * @returns A Uint8Array filled with random bytes.\n */\nconst generateRandomBytes = (size: number): Uint8Array =>\n typeof crypto?.getRandomValues === 'function'\n ? crypto.getRandomValues(new Uint8Array(size))\n : require('crypto').randomFillSync(new Uint8Array(size));\n\n/*\n @randomString: randomString = (length = 32, chars = base62Characters, randomNumbers) ->\n result = ''\n charsLength = chars.length\n if randomNumbers\n (chars[randomNumbers[i] % charsLength] for i in [0...length] by 1).join ''\n else\n (chars[intRand charsLength] for i in [0...length] by 1).join ''\n*/\nexport const randomString = (length = 32, chars = base62Characters, randomNumbers?: Uint8Array | number[]): string => {\n const charsLength = chars.length\n let result = ''\n if (randomNumbers) {\n for (let i = 0; i < length; i++) result += chars[randomNumbers[i] % charsLength]\n } else {\n for (let i = 0; i < length; i++) result += chars[intRand(charsLength)]\n }\n return result\n}\n\nexport const cryptoRandomString = (length = 32, chars = base62Characters): string =>\n randomString(length, chars, generateRandomBytes(length).map(b => b % chars.length))"],"x_google_ignoreList":[1],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAKA,MAAa,YAAY,MAAuB,EAAE,UAAU,CAAC,QAAQ,yBAAyB,IAAI;;;;ACHlG,EAAC,SAAU,MAAM,WAAW;;AAE1B,MAAI,OAAA,cAAmB,cAAc,OAAO,YAAY,YAAY,OAAO,WAAW,SAEpF,QAAO,UAAU,WAAW;WACnB,OAAO,WAAW,cAAc,OAAO,IAEhD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AC,4FAA4F,KAAK;GAClG,CAAC,sEAAsE,QAAQ;GAC/E,CAAC,kCAAkC,KAAK;GACxC,CAAC,qBAAqB,OAAO;GAC7B,CAAC,6FAA6F,OAAO;GACrG,CAAC,0GAA0G,OAAO;GAClH,CAAC,+FAA+F,OAAO;GACvG,CAAC,2BAA2B,MAAM;GAClC,CAAC,gCAAgC,OAAO;GACxC,CAAC,uBAAuB,OAAO;GAC/B,CAAC,qBAAqB,SAAS;GAC/B,CAAC,gBAAgB,KAAK;GACtB,CAAC,aAAa,KAAK;GACnB,CAAC,SAAS,MAAM;GACjB,CAAC,QAAQ,SAAU,MAAM;AACxB,UAAO,UAAU,gBAAgB,KAAK,IAAI,KAAK,GAAG;IAClD;;;;AAKF;GAEE;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GAEA;GACA;GACA;GACA;GACA;GACA;GACA;GACD,CAAC,QAAQ,UAAU,mBAAmB;AAEvC,SAAO;GACP;;ACnfF,MAAM,uBAAuB,MAAc,OAA4B,cAAoC;CACzG,MAAM,QAAQ,kBAAkB,KAAK,KAAK;AAC1C,KAAI,OAAO;EACT,MAAM,CAAC,IAAI,UAAU,UAAU;AAE/B,UAAA,GAAA,iBAAA,SADyB,UAAU,OAAO,UAAU,GACvC;;AAEf,SAAA,GAAA,iBAAA,SAAoB,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KAEpE,MAAK,IAAI,IAAI,GAAG,IAAI,QAAQ,IAAK,WAAU,MAAM,QAAQ,YAAY;AAEvE,QAAO;;AAGT,MAAa,sBAAsB,SAAS,IAAI,QAAQ,qBACtD,aAAa,QAAQ,OAAO,oBAAoB,OAAO,CAAC,KAAI,MAAK,IAAI,MAAM,OAAO,CAAA"}
|
|
1
|
+
{"version":3,"file":"index.mjs","names":[],"sources":["../src/commaize.ts","../src/pluralize.ts","../src/randomString.ts"],"sourcesContent":["/**\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-esm'\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","export const base62Characters = \"0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ\"\n\nconst intRand = (max: number): number => {\n return Math.floor(Math.random() * max)\n}\n/**\n * Generates a Uint8Array of cryptographically secure random bytes.\n * @param size Number of bytes to generate.\n * @returns A Uint8Array filled with random bytes.\n */\nconst generateRandomBytes = (size: number): Uint8Array =>\n crypto.getRandomValues(new Uint8Array(size))\n\n/*\n @randomString: randomString = (length = 32, chars = base62Characters, randomNumbers) ->\n result = ''\n charsLength = chars.length\n if randomNumbers\n (chars[randomNumbers[i] % charsLength] for i in [0...length] by 1).join ''\n else\n (chars[intRand charsLength] for i in [0...length] by 1).join ''\n*/\nexport const randomString = (length = 32, chars = base62Characters, randomNumbers?: Uint8Array | number[]): string => {\n const charsLength = chars.length\n let result = ''\n if (randomNumbers) {\n for (let i = 0; i < length; i++) result += chars[randomNumbers[i] % charsLength]\n } else {\n for (let i = 0; i < length; i++) result += chars[intRand(charsLength)]\n }\n return result\n}\n\nexport const cryptoRandomString = (length = 32, chars = base62Characters): string =>\n randomString(length, chars, generateRandomBytes(length).map(b => b % chars.length))"],"mappings":";;;;;;;;AAKA,MAAa,YAAY,MAAuB,EAAE,UAAU,CAAC,QAAQ,yBAAyB,IAAI;;;ACFlG,MAAM,uBAAuB,MAAc,OAA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,cACF,MAAK,IAAI,IAAI,GAAG,IAAI,QAAQ,IAAK,WAAU,MAAM,cAAc,KAAK;KAEpE,MAAK,IAAI,IAAI,GAAG,IAAI,QAAQ,IAAK,WAAU,MAAM,QAAQ,YAAY;AAEvE,QAAO;;AAGT,MAAa,sBAAsB,SAAS,IAAI,QAAQ,qBACtD,aAAa,QAAQ,OAAO,oBAAoB,OAAO,CAAC,KAAI,MAAK,IAAI,MAAM,OAAO,CAAA"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@art-suite/art-core-ts-string-lib",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "1.0.0",
|
|
4
4
|
"description": "A TypeScript string utility library",
|
|
5
5
|
"keywords": [],
|
|
6
6
|
"repository": {
|
|
@@ -35,7 +35,8 @@
|
|
|
35
35
|
"test:watch": "vitest"
|
|
36
36
|
},
|
|
37
37
|
"dependencies": {
|
|
38
|
-
"@art-suite/art-core-ts-types": "^0.4.0"
|
|
38
|
+
"@art-suite/art-core-ts-types": "^0.4.0",
|
|
39
|
+
"pluralize-esm": "^9.0.5"
|
|
39
40
|
},
|
|
40
41
|
"devDependencies": {
|
|
41
42
|
"@vitest/coverage-v8": "^4.0.18"
|