nhb-toolbox 4.13.3 → 4.13.6
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/CHANGELOG.md +4 -0
- package/dist/cjs/pluralize/Pluralizer.js +10 -3
- package/dist/cjs/pluralize/rules.js +11 -12
- package/dist/dts/pluralize/Pluralizer.d.ts +8 -1
- package/dist/dts/pluralize/Pluralizer.d.ts.map +1 -1
- package/dist/dts/pluralize/rules.d.ts.map +1 -1
- package/dist/esm/pluralize/Pluralizer.js +10 -3
- package/dist/esm/pluralize/rules.js +11 -12
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -6,6 +6,10 @@ All notable changes to the package will be documented here.
|
|
|
6
6
|
|
|
7
7
|
---
|
|
8
8
|
|
|
9
|
+
## [4.13.3-6] - 2025-07-22
|
|
10
|
+
|
|
11
|
+
- **Reordered** rules for `pluralizer` and fixed other issues.
|
|
12
|
+
|
|
9
13
|
## [4.13.3] - 2025-07-22
|
|
10
14
|
|
|
11
15
|
- **Updated** pluralization/uncountable rules, case restoration method and fixed other bugs in `pluralizer`.
|
|
@@ -126,9 +126,6 @@ class Pluralizer {
|
|
|
126
126
|
addSingularRule(rule, replacement) {
|
|
127
127
|
this.#singularRules.push([rule, replacement]);
|
|
128
128
|
}
|
|
129
|
-
addUncountable(word) {
|
|
130
|
-
this.#uncountables.add(typeof word === 'string' ? word?.toLowerCase() : word);
|
|
131
|
-
}
|
|
132
129
|
/**
|
|
133
130
|
* * Add a word or pattern that should never change between singular and plural.
|
|
134
131
|
* @param word A word or regex pattern.
|
|
@@ -136,6 +133,16 @@ class Pluralizer {
|
|
|
136
133
|
* pluralizer.addUncountable('fish');
|
|
137
134
|
* pluralizer.addUncountable(/pok[eé]mon$/i);
|
|
138
135
|
*/
|
|
136
|
+
addUncountable(word) {
|
|
137
|
+
this.#uncountables.add(typeof word === 'string' ? word?.toLowerCase() : word);
|
|
138
|
+
}
|
|
139
|
+
/**
|
|
140
|
+
* * Add a custom irregular form.
|
|
141
|
+
* @param single Singular word.
|
|
142
|
+
* @param plural Plural word.
|
|
143
|
+
* @example
|
|
144
|
+
* pluralizer.addIrregular('person', 'people');
|
|
145
|
+
*/
|
|
139
146
|
addIrregular(single, plural) {
|
|
140
147
|
const singleLower = single?.toLowerCase();
|
|
141
148
|
const pluralLower = plural?.toLowerCase();
|
|
@@ -61,6 +61,7 @@ exports.irregularRules =
|
|
|
61
61
|
['pickaxe', 'pickaxes'],
|
|
62
62
|
['passerby', 'passersby'],
|
|
63
63
|
['honey', 'honeys'],
|
|
64
|
+
['virus', 'viruses'],
|
|
64
65
|
// Words ending in with a consonant and `o`.
|
|
65
66
|
['echo', 'echoes'],
|
|
66
67
|
['dingo', 'dingoes'],
|
|
@@ -82,14 +83,11 @@ exports.irregularRules =
|
|
|
82
83
|
/** Plural rules and replacements */
|
|
83
84
|
exports.pluralRules =
|
|
84
85
|
/* @__PURE__ */ Object.freeze([
|
|
86
|
+
[/s$/i, 's'],
|
|
85
87
|
[/(\P{ASCII})$/u, '$1'],
|
|
86
88
|
[/(pe)(rson|ople)$/i, '$1ople'],
|
|
87
89
|
[/(child)(?:ren)?$/i, '$1ren'],
|
|
88
90
|
[/(matr|cod|mur|sil|vert|ind|append)(?:ix|ex)$/i, '$1ices'],
|
|
89
|
-
[
|
|
90
|
-
/(alumn|syllab|vir|radi|nucle|fung|cact|stimul|termin|bacill|foc|uter|loc|strat)(?:us|i)$/i,
|
|
91
|
-
'$1i',
|
|
92
|
-
],
|
|
93
91
|
[/(alumn|alg|vertebr)(?:a|ae)$/i, '$1ae'],
|
|
94
92
|
[
|
|
95
93
|
/(apheli|hyperbat|periheli|asyndet|noumen|phenomen|criteri|organ|prolegomen|hedr|automat)a$/i,
|
|
@@ -115,8 +113,10 @@ exports.pluralRules =
|
|
|
115
113
|
[/(quiz)$/i, '$1zes'],
|
|
116
114
|
[/m[ae]n$/i, 'men'],
|
|
117
115
|
[/eaux$/i, '$0'],
|
|
118
|
-
|
|
119
|
-
|
|
116
|
+
[
|
|
117
|
+
/(alumn|syllab|vir|radi|nucle|fung|cact|stimul|termin|bacill|foc|uter|loc|strat)(?:us|i)$/i,
|
|
118
|
+
'$1i',
|
|
119
|
+
],
|
|
120
120
|
]);
|
|
121
121
|
/** Uncountable constants */
|
|
122
122
|
exports.uncountables = Object.freeze(new Set([
|
|
@@ -376,6 +376,7 @@ exports.uncountables = Object.freeze(new Set([
|
|
|
376
376
|
/** Singular rules and replacements */
|
|
377
377
|
exports.singularRules =
|
|
378
378
|
/* @__PURE__ */ Object.freeze([
|
|
379
|
+
[/s$/i, ''],
|
|
379
380
|
[/(\P{ASCII})$/u, '$1'],
|
|
380
381
|
[/(pe)(rson|ople)$/i, '$1rson'],
|
|
381
382
|
[/(child)ren$/i, '$1'],
|
|
@@ -392,10 +393,6 @@ exports.singularRules =
|
|
|
392
393
|
/(agend|addend|millenni|dat|extrem|bacteri|desiderat|strat|candelabr|errat|ov|symposi|curricul|quor)a$/i,
|
|
393
394
|
'$1um',
|
|
394
395
|
],
|
|
395
|
-
[
|
|
396
|
-
/(alumn|syllab|vir|radi|nucle|fung|cact|stimul|termin|bacill|foc|uter|loc|strat)(?:us|i)$/i,
|
|
397
|
-
'$1us',
|
|
398
|
-
],
|
|
399
396
|
[/(test)(?:is|es)$/i, '$1is'],
|
|
400
397
|
[/(movie|twelve|abuse|e[mn]u)s$/i, '$1'],
|
|
401
398
|
[
|
|
@@ -438,6 +435,8 @@ exports.singularRules =
|
|
|
438
435
|
[/(^analy)ses$/i, '$1sis'],
|
|
439
436
|
[/([ti])a$/i, '$1um'],
|
|
440
437
|
[/(n)ews$/i, '$1ews'],
|
|
441
|
-
|
|
442
|
-
|
|
438
|
+
[
|
|
439
|
+
/(alumn|syllab|vir|radi|nucle|fung|cact|stimul|termin|bacill|foc|uter|loc|strat)(?:us|i)$/i,
|
|
440
|
+
'$1us',
|
|
441
|
+
],
|
|
443
442
|
]);
|
|
@@ -42,7 +42,6 @@ export declare class Pluralizer {
|
|
|
42
42
|
* pluralizer.addSingularRule(/(matr)ices$/i, '$1ix');
|
|
43
43
|
*/
|
|
44
44
|
addSingularRule(rule: RegExp, replacement: string): void;
|
|
45
|
-
addUncountable(word: string | RegExp): void;
|
|
46
45
|
/**
|
|
47
46
|
* * Add a word or pattern that should never change between singular and plural.
|
|
48
47
|
* @param word A word or regex pattern.
|
|
@@ -50,6 +49,14 @@ export declare class Pluralizer {
|
|
|
50
49
|
* pluralizer.addUncountable('fish');
|
|
51
50
|
* pluralizer.addUncountable(/pok[eé]mon$/i);
|
|
52
51
|
*/
|
|
52
|
+
addUncountable(word: string | RegExp): void;
|
|
53
|
+
/**
|
|
54
|
+
* * Add a custom irregular form.
|
|
55
|
+
* @param single Singular word.
|
|
56
|
+
* @param plural Plural word.
|
|
57
|
+
* @example
|
|
58
|
+
* pluralizer.addIrregular('person', 'people');
|
|
59
|
+
*/
|
|
53
60
|
addIrregular(single: string, plural: string): void;
|
|
54
61
|
/**
|
|
55
62
|
* * Get the proper singular or plural form based on optional count.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Pluralizer.d.ts","sourceRoot":"","sources":["../../../src/pluralize/Pluralizer.ts"],"names":[],"mappings":"AAQA,OAAO,KAAK,EAAgB,gBAAgB,EAAiB,MAAM,SAAS,CAAC;AAE7E;;;;;;;;;;;;;;;;;;;GAmBG;AACH,qBAAa,UAAU;;IAOtB;;;OAGG;;IAoFH;;;;;;OAMG;IACH,aAAa,CAAC,IAAI,EAAE,MAAM,EAAE,WAAW,EAAE,MAAM,GAAG,IAAI;IAItD;;;;;;OAMG;IACH,eAAe,CAAC,IAAI,EAAE,MAAM,EAAE,WAAW,EAAE,MAAM,GAAG,IAAI;IAIxD,cAAc,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI;IAM3C;;;;;;OAMG;IACH,YAAY,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAA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,EAAE,MAAM,GAAG,MAAM;IAiBhC;;;;;;OAMG;IACH,QAAQ,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO;IAO/B;;;;;;OAMG;IACH,UAAU,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO;CAMjC;AAED;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,eAAO,MAAM,UAAU,YAAmB,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"rules.d.ts","sourceRoot":"","sources":["../../../src/pluralize/rules.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AAE7C,uCAAuC;AACvC,eAAO,MAAM,cAAc,EAAE,SAAS,CAAC,MAAM,EAAE,MAAM,CAAC,
|
|
1
|
+
{"version":3,"file":"rules.d.ts","sourceRoot":"","sources":["../../../src/pluralize/rules.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AAE7C,uCAAuC;AACvC,eAAO,MAAM,cAAc,EAAE,SAAS,CAAC,MAAM,EAAE,MAAM,CAAC,EAgFnD,CAAC;AAEJ,oCAAoC;AACpC,eAAO,MAAM,WAAW,EAAE,SAAS,aAAa,EAoC7C,CAAC;AAEJ,4BAA4B;AAC5B,eAAO,MAAM,YAAY,gCAiQxB,CAAC;AAEF,sCAAsC;AACtC,eAAO,MAAM,aAAa,EAAE,SAAS,aAAa,EAiE/C,CAAC"}
|
|
@@ -123,9 +123,6 @@ export class Pluralizer {
|
|
|
123
123
|
addSingularRule(rule, replacement) {
|
|
124
124
|
this.#singularRules.push([rule, replacement]);
|
|
125
125
|
}
|
|
126
|
-
addUncountable(word) {
|
|
127
|
-
this.#uncountables.add(typeof word === 'string' ? word?.toLowerCase() : word);
|
|
128
|
-
}
|
|
129
126
|
/**
|
|
130
127
|
* * Add a word or pattern that should never change between singular and plural.
|
|
131
128
|
* @param word A word or regex pattern.
|
|
@@ -133,6 +130,16 @@ export class Pluralizer {
|
|
|
133
130
|
* pluralizer.addUncountable('fish');
|
|
134
131
|
* pluralizer.addUncountable(/pok[eé]mon$/i);
|
|
135
132
|
*/
|
|
133
|
+
addUncountable(word) {
|
|
134
|
+
this.#uncountables.add(typeof word === 'string' ? word?.toLowerCase() : word);
|
|
135
|
+
}
|
|
136
|
+
/**
|
|
137
|
+
* * Add a custom irregular form.
|
|
138
|
+
* @param single Singular word.
|
|
139
|
+
* @param plural Plural word.
|
|
140
|
+
* @example
|
|
141
|
+
* pluralizer.addIrregular('person', 'people');
|
|
142
|
+
*/
|
|
136
143
|
addIrregular(single, plural) {
|
|
137
144
|
const singleLower = single?.toLowerCase();
|
|
138
145
|
const pluralLower = plural?.toLowerCase();
|
|
@@ -58,6 +58,7 @@ export const irregularRules =
|
|
|
58
58
|
['pickaxe', 'pickaxes'],
|
|
59
59
|
['passerby', 'passersby'],
|
|
60
60
|
['honey', 'honeys'],
|
|
61
|
+
['virus', 'viruses'],
|
|
61
62
|
// Words ending in with a consonant and `o`.
|
|
62
63
|
['echo', 'echoes'],
|
|
63
64
|
['dingo', 'dingoes'],
|
|
@@ -79,14 +80,11 @@ export const irregularRules =
|
|
|
79
80
|
/** Plural rules and replacements */
|
|
80
81
|
export const pluralRules =
|
|
81
82
|
/* @__PURE__ */ Object.freeze([
|
|
83
|
+
[/s$/i, 's'],
|
|
82
84
|
[/(\P{ASCII})$/u, '$1'],
|
|
83
85
|
[/(pe)(rson|ople)$/i, '$1ople'],
|
|
84
86
|
[/(child)(?:ren)?$/i, '$1ren'],
|
|
85
87
|
[/(matr|cod|mur|sil|vert|ind|append)(?:ix|ex)$/i, '$1ices'],
|
|
86
|
-
[
|
|
87
|
-
/(alumn|syllab|vir|radi|nucle|fung|cact|stimul|termin|bacill|foc|uter|loc|strat)(?:us|i)$/i,
|
|
88
|
-
'$1i',
|
|
89
|
-
],
|
|
90
88
|
[/(alumn|alg|vertebr)(?:a|ae)$/i, '$1ae'],
|
|
91
89
|
[
|
|
92
90
|
/(apheli|hyperbat|periheli|asyndet|noumen|phenomen|criteri|organ|prolegomen|hedr|automat)a$/i,
|
|
@@ -112,8 +110,10 @@ export const pluralRules =
|
|
|
112
110
|
[/(quiz)$/i, '$1zes'],
|
|
113
111
|
[/m[ae]n$/i, 'men'],
|
|
114
112
|
[/eaux$/i, '$0'],
|
|
115
|
-
|
|
116
|
-
|
|
113
|
+
[
|
|
114
|
+
/(alumn|syllab|vir|radi|nucle|fung|cact|stimul|termin|bacill|foc|uter|loc|strat)(?:us|i)$/i,
|
|
115
|
+
'$1i',
|
|
116
|
+
],
|
|
117
117
|
]);
|
|
118
118
|
/** Uncountable constants */
|
|
119
119
|
export const uncountables = /* @__PURE__ */ Object.freeze(new Set([
|
|
@@ -373,6 +373,7 @@ export const uncountables = /* @__PURE__ */ Object.freeze(new Set([
|
|
|
373
373
|
/** Singular rules and replacements */
|
|
374
374
|
export const singularRules =
|
|
375
375
|
/* @__PURE__ */ Object.freeze([
|
|
376
|
+
[/s$/i, ''],
|
|
376
377
|
[/(\P{ASCII})$/u, '$1'],
|
|
377
378
|
[/(pe)(rson|ople)$/i, '$1rson'],
|
|
378
379
|
[/(child)ren$/i, '$1'],
|
|
@@ -389,10 +390,6 @@ export const singularRules =
|
|
|
389
390
|
/(agend|addend|millenni|dat|extrem|bacteri|desiderat|strat|candelabr|errat|ov|symposi|curricul|quor)a$/i,
|
|
390
391
|
'$1um',
|
|
391
392
|
],
|
|
392
|
-
[
|
|
393
|
-
/(alumn|syllab|vir|radi|nucle|fung|cact|stimul|termin|bacill|foc|uter|loc|strat)(?:us|i)$/i,
|
|
394
|
-
'$1us',
|
|
395
|
-
],
|
|
396
393
|
[/(test)(?:is|es)$/i, '$1is'],
|
|
397
394
|
[/(movie|twelve|abuse|e[mn]u)s$/i, '$1'],
|
|
398
395
|
[
|
|
@@ -435,6 +432,8 @@ export const singularRules =
|
|
|
435
432
|
[/(^analy)ses$/i, '$1sis'],
|
|
436
433
|
[/([ti])a$/i, '$1um'],
|
|
437
434
|
[/(n)ews$/i, '$1ews'],
|
|
438
|
-
|
|
439
|
-
|
|
435
|
+
[
|
|
436
|
+
/(alumn|syllab|vir|radi|nucle|fung|cact|stimul|termin|bacill|foc|uter|loc|strat)(?:us|i)$/i,
|
|
437
|
+
'$1us',
|
|
438
|
+
],
|
|
440
439
|
]);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "nhb-toolbox",
|
|
3
|
-
"version": "4.13.
|
|
3
|
+
"version": "4.13.6",
|
|
4
4
|
"description": "A versatile collection of smart, efficient, and reusable utility functions and classes for everyday development needs.",
|
|
5
5
|
"main": "dist/cjs/index.js",
|
|
6
6
|
"module": "dist/esm/index.js",
|