@art-suite/art-core-ts-string-lib 0.2.12 → 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 CHANGED
@@ -1,487 +1,131 @@
1
- "use strict";
1
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
+ //#region \0rolldown/runtime.js
2
3
  var __create = Object.create;
3
4
  var __defProp = Object.defineProperty;
4
5
  var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
6
  var __getOwnPropNames = Object.getOwnPropertyNames;
6
7
  var __getProtoOf = Object.getPrototypeOf;
7
8
  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
9
  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;
10
+ if (from && typeof from === "object" || typeof from === "function") for (var keys = __getOwnPropNames(from), i = 0, n = keys.length, key; i < n; i++) {
11
+ key = keys[i];
12
+ if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
13
+ get: ((k) => from[k]).bind(null, key),
14
+ enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
15
+ });
16
+ }
17
+ return to;
22
18
  };
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
- base62Characters: () => base62Characters,
393
- commaize: () => commaize,
394
- cryptoRandomString: () => cryptoRandomString,
395
- isPlural: () => isPlural,
396
- isSingular: () => isSingular,
397
- plural: () => plural,
398
- pluralize: () => pluralize,
399
- randomString: () => randomString,
400
- singular: () => singular
401
- });
402
- module.exports = __toCommonJS(index_exports);
403
-
404
- // src/commaize.ts
405
- var commaize = (x) => x.toString().replace(/\B(?=(\d{3})+(?!\d))/g, ",");
406
-
407
- // src/pluralize.ts
408
- var import_pluralize = __toESM(require_pluralize(), 1);
409
- var import_art_core_ts_types = require("@art-suite/art-core-ts-types");
410
- var patchedNpmPluralize = (noun, count, inclusive) => {
411
- const match = /^(.*?)([_\W]+)$/.exec(noun);
412
- if (match) {
413
- const [__, mainNoun, append] = match;
414
- const out = (0, import_pluralize.default)(mainNoun, count, inclusive);
415
- return out + append;
416
- }
417
- return (0, import_pluralize.default)(noun, count, inclusive);
19
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
20
+ value: mod,
21
+ enumerable: true
22
+ }) : target, mod));
23
+ //#endregion
24
+ let pluralize_esm = require("pluralize-esm");
25
+ pluralize_esm = __toESM(pluralize_esm);
26
+ let _art_suite_art_core_ts_types = require("@art-suite/art-core-ts-types");
27
+ //#region src/commaize.ts
28
+ /**
29
+ * Adds commas to a number or string
30
+ * @param x - The number or string to commaize
31
+ * @returns The commaized number or string
32
+ */
33
+ const commaize = (x) => x.toString().replace(/\B(?=(\d{3})+(?!\d))/g, ",");
34
+ //#endregion
35
+ //#region src/pluralize.ts
36
+ const patchedNpmPluralize = (noun, count, inclusive) => {
37
+ const match = /^(.*?)([_\W]+)$/.exec(noun);
38
+ if (match) {
39
+ const [__, mainNoun, append] = match;
40
+ return (0, pluralize_esm.default)(mainNoun, count, inclusive) + append;
41
+ }
42
+ return (0, pluralize_esm.default)(noun, count, inclusive);
418
43
  };
419
- var {
420
- plural,
421
- singular,
422
- isSingular,
423
- isPlural,
424
- addPluralRule,
425
- addSingularRule,
426
- addIrregularRule,
427
- addUncountableRule
428
- } = import_pluralize.default;
429
- var pluralize = (a, b, pluralForm) => {
430
- let singleForm;
431
- let number = null;
432
- if ((0, import_art_core_ts_types.isNumber)(b)) {
433
- if (!(0, import_art_core_ts_types.isString)(a)) {
434
- throw new Error(`singleForm and pluralForm(optional) should be non-empty strings (inputs: ${JSON.stringify({ a, b, pluralForm })}`);
435
- }
436
- singleForm = a;
437
- number = b;
438
- } else if ((0, import_art_core_ts_types.isNumber)(a)) {
439
- if (!(0, import_art_core_ts_types.isString)(b)) {
440
- throw new Error(`singleForm and pluralForm(optional) should be non-empty strings (inputs: ${JSON.stringify({ a, b, pluralForm })}`);
441
- }
442
- singleForm = b;
443
- number = a;
444
- } else {
445
- 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 })}`);
446
- singleForm = a;
447
- number = null;
448
- }
449
- if (pluralForm) return `${number} ${number == 1 ? singleForm : pluralForm}`;
450
- if (number != null) return patchedNpmPluralize(singleForm, number, true);
451
- return patchedNpmPluralize(singleForm);
44
+ const { plural, singular, isSingular, isPlural, addPluralRule, addSingularRule, addIrregularRule, addUncountableRule } = pluralize_esm.default;
45
+ /**
46
+ * Pluralize a word based on the passed in count. Call signatures:
47
+ *
48
+ * 1 input:
49
+ * pluralize(singleForm: string)
50
+ *
51
+ * 2 inputS:
52
+ * pluralize(singleForm: string, count: number)
53
+ * pluralize(count: number, singleForm: string)
54
+ *
55
+ * 3 inputs:
56
+ * pluralize(singleForm: string, count: number, pluralForm: string)
57
+ * pluralize(count: number, singleForm: string, pluralForm: string)
58
+ *
59
+ * @param a: string | number - The word to pluralize if a string, or the count if a number
60
+ * @param b: string | number - The count to pluralize the word by if a number, or the singleForm if a string
61
+ * @param pluralForm: string - Explicitly provide the plural form of the word (optional)
62
+ * @returns The pluralized word
63
+ */
64
+ const pluralize = (a, b, pluralForm) => {
65
+ let singleForm;
66
+ let number = null;
67
+ if ((0, _art_suite_art_core_ts_types.isNumber)(b)) {
68
+ if (!(0, _art_suite_art_core_ts_types.isString)(a)) throw new Error(`singleForm and pluralForm(optional) should be non-empty strings (inputs: ${JSON.stringify({
69
+ a,
70
+ b,
71
+ pluralForm
72
+ })}`);
73
+ singleForm = a;
74
+ number = b;
75
+ } else if ((0, _art_suite_art_core_ts_types.isNumber)(a)) {
76
+ if (!(0, _art_suite_art_core_ts_types.isString)(b)) throw new Error(`singleForm and pluralForm(optional) should be non-empty strings (inputs: ${JSON.stringify({
77
+ a,
78
+ b,
79
+ pluralForm
80
+ })}`);
81
+ singleForm = b;
82
+ number = a;
83
+ } else {
84
+ if (!(0, _art_suite_art_core_ts_types.isString)(a)) throw new Error(`singleForm and pluralForm(optional) should be non-empty strings (inputs: ${JSON.stringify({
85
+ a,
86
+ b,
87
+ pluralForm
88
+ })}`);
89
+ singleForm = a;
90
+ number = null;
91
+ }
92
+ if (pluralForm) return `${number} ${number == 1 ? singleForm : pluralForm}`;
93
+ if (number != null) return patchedNpmPluralize(singleForm, number, true);
94
+ return patchedNpmPluralize(singleForm);
452
95
  };
453
-
454
- // src/randomString.ts
455
- var base62Characters = "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ";
456
- var intRand = (max) => {
457
- return Math.floor(Math.random() * max);
96
+ //#endregion
97
+ //#region src/randomString.ts
98
+ const base62Characters = "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ";
99
+ const intRand = (max) => {
100
+ return Math.floor(Math.random() * max);
458
101
  };
459
- var generateRandomBytes = (size) => typeof crypto?.getRandomValues === "function" ? crypto.getRandomValues(new Uint8Array(size)) : require("crypto").randomFillSync(new Uint8Array(size));
460
- var randomString = (length = 32, chars = base62Characters, randomNumbers) => {
461
- const charsLength = chars.length;
462
- let result = "";
463
- if (randomNumbers) {
464
- for (let i = 0; i < length; i++) result += chars[randomNumbers[i] % charsLength];
465
- } else {
466
- for (let i = 0; i < length; i++) result += chars[intRand(charsLength)];
467
- }
468
- return result;
102
+ /**
103
+ * Generates a Uint8Array of cryptographically secure random bytes.
104
+ * @param size Number of bytes to generate.
105
+ * @returns A Uint8Array filled with random bytes.
106
+ */
107
+ const generateRandomBytes = (size) => crypto.getRandomValues(new Uint8Array(size));
108
+ const randomString = (length = 32, chars = base62Characters, randomNumbers) => {
109
+ const charsLength = chars.length;
110
+ let result = "";
111
+ if (randomNumbers) for (let i = 0; i < length; i++) result += chars[randomNumbers[i] % charsLength];
112
+ else for (let i = 0; i < length; i++) result += chars[intRand(charsLength)];
113
+ return result;
469
114
  };
470
- var cryptoRandomString = (length = 32, chars = base62Characters) => randomString(length, chars, generateRandomBytes(length).map((b) => b % chars.length));
471
- // Annotate the CommonJS export names for ESM import in node:
472
- 0 && (module.exports = {
473
- addIrregularRule,
474
- addPluralRule,
475
- addSingularRule,
476
- addUncountableRule,
477
- base62Characters,
478
- commaize,
479
- cryptoRandomString,
480
- isPlural,
481
- isSingular,
482
- plural,
483
- pluralize,
484
- randomString,
485
- singular
486
- });
115
+ const cryptoRandomString = (length = 32, chars = base62Characters) => randomString(length, chars, generateRandomBytes(length).map((b) => b % chars.length));
116
+ //#endregion
117
+ exports.addIrregularRule = addIrregularRule;
118
+ exports.addPluralRule = addPluralRule;
119
+ exports.addSingularRule = addSingularRule;
120
+ exports.addUncountableRule = addUncountableRule;
121
+ exports.base62Characters = base62Characters;
122
+ exports.commaize = commaize;
123
+ exports.cryptoRandomString = cryptoRandomString;
124
+ exports.isPlural = isPlural;
125
+ exports.isSingular = isSingular;
126
+ exports.plural = plural;
127
+ exports.pluralize = pluralize;
128
+ exports.randomString = randomString;
129
+ exports.singular = singular;
130
+
487
131
  //# sourceMappingURL=index.cjs.map