@bccampus/utils 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +8 -0
- package/dist/array/chunk.d.ts +1 -0
- package/dist/array/chunk.js +9 -0
- package/dist/array/index.d.ts +1 -0
- package/dist/array/index.js +4 -0
- package/dist/date/index.d.ts +1 -0
- package/dist/date/index.js +8 -0
- package/dist/date/iso-date-time.d.ts +127 -0
- package/dist/date/iso-date-time.js +256 -0
- package/dist/duration/add-durations.d.ts +1 -0
- package/dist/duration/add-durations.js +12 -0
- package/dist/duration/index.d.ts +3 -0
- package/dist/duration/index.js +8 -0
- package/dist/duration/is-duration.d.ts +1 -0
- package/dist/duration/is-duration.js +7 -0
- package/dist/duration/to-number.d.ts +1 -0
- package/dist/duration/to-number.js +14 -0
- package/dist/format/formatter.d.ts +5 -0
- package/dist/format/formatter.js +40 -0
- package/dist/format/index.d.ts +3 -0
- package/dist/format/index.js +13 -0
- package/dist/format/stringify.d.ts +38 -0
- package/dist/format/stringify.js +42 -0
- package/dist/format/template.d.ts +6 -0
- package/dist/format/template.js +35 -0
- package/dist/object/get.d.ts +1 -0
- package/dist/object/get.js +7 -0
- package/dist/object/index.d.ts +5 -0
- package/dist/object/index.js +12 -0
- package/dist/object/is-object.d.ts +1 -0
- package/dist/object/is-object.js +4 -0
- package/dist/object/omit.d.ts +1 -0
- package/dist/object/omit.js +18 -0
- package/dist/object/pick.d.ts +1 -0
- package/dist/object/pick.js +11 -0
- package/dist/object/set.d.ts +1 -0
- package/dist/object/set.js +14 -0
- package/dist/set/difference.d.ts +1 -0
- package/dist/set/difference.js +10 -0
- package/dist/set/index.d.ts +5 -0
- package/dist/set/index.js +12 -0
- package/dist/set/intersection.d.ts +1 -0
- package/dist/set/intersection.js +13 -0
- package/dist/set/is-superset.d.ts +1 -0
- package/dist/set/is-superset.js +12 -0
- package/dist/set/symmetric-difference.d.ts +1 -0
- package/dist/set/symmetric-difference.js +14 -0
- package/dist/set/union.d.ts +1 -0
- package/dist/set/union.js +10 -0
- package/dist/string/capitalize.d.ts +1 -0
- package/dist/string/capitalize.js +4 -0
- package/dist/string/index.d.ts +6 -0
- package/dist/string/index.js +14 -0
- package/dist/string/pluralize/index.d.ts +2 -0
- package/dist/string/pluralize/index.js +4 -0
- package/dist/string/pluralize/pluralize.d.ts +85 -0
- package/dist/string/pluralize/pluralize.js +210 -0
- package/dist/string/pluralize/rules/index.d.ts +4 -0
- package/dist/string/pluralize/rules/index.js +10 -0
- package/dist/string/pluralize/rules/irregular.d.ts +1 -0
- package/dist/string/pluralize/rules/irregular.js +62 -0
- package/dist/string/pluralize/rules/pluralization.d.ts +2 -0
- package/dist/string/pluralize/rules/pluralization.js +39 -0
- package/dist/string/pluralize/rules/singularization.d.ts +2 -0
- package/dist/string/pluralize/rules/singularization.js +47 -0
- package/dist/string/pluralize/rules/uncountable.d.ts +2 -0
- package/dist/string/pluralize/rules/uncountable.js +113 -0
- package/dist/string/pluralize/types.d.ts +3 -0
- package/dist/string/pluralize/types.js +1 -0
- package/dist/string/slugify/index.d.ts +1 -0
- package/dist/string/slugify/index.js +2263 -0
- package/dist/string/strip-html-tags.d.ts +1 -0
- package/dist/string/strip-html-tags.js +7 -0
- package/dist/string/to-int.d.ts +9 -0
- package/dist/string/to-int.js +10 -0
- package/dist/string/to-sentence-case.d.ts +1 -0
- package/dist/string/to-sentence-case.js +8 -0
- package/dist/string/trim.d.ts +1 -0
- package/dist/string/trim.js +11 -0
- package/dist/string/truncate.d.ts +1 -0
- package/dist/string/truncate.js +9 -0
- package/eslint.config.js +19 -0
- package/package.json +68 -0
- package/src/array/chunk.ts +6 -0
- package/src/array/index.ts +1 -0
- package/src/date/index.ts +1 -0
- package/src/date/iso-date-time.ts +356 -0
- package/src/duration/add-durations.ts +16 -0
- package/src/duration/index.ts +3 -0
- package/src/duration/is-duration.ts +5 -0
- package/src/duration/to-number.ts +18 -0
- package/src/format/formatter.ts +37 -0
- package/src/format/index.ts +3 -0
- package/src/format/stringify.ts +87 -0
- package/src/format/template.ts +48 -0
- package/src/object/get.ts +9 -0
- package/src/object/index.ts +5 -0
- package/src/object/is-object.ts +2 -0
- package/src/object/omit.ts +21 -0
- package/src/object/pick.ts +10 -0
- package/src/object/set.ts +15 -0
- package/src/set/difference.ts +9 -0
- package/src/set/index.ts +5 -0
- package/src/set/intersection.ts +12 -0
- package/src/set/is-superset.ts +12 -0
- package/src/set/symmetric-difference.ts +12 -0
- package/src/set/union.ts +8 -0
- package/src/string/capitalize.ts +2 -0
- package/src/string/index.ts +6 -0
- package/src/string/pluralize/index.ts +2 -0
- package/src/string/pluralize/pluralize.ts +296 -0
- package/src/string/pluralize/rules/index.ts +4 -0
- package/src/string/pluralize/rules/irregular.ts +59 -0
- package/src/string/pluralize/rules/pluralization.ts +40 -0
- package/src/string/pluralize/rules/singularization.ts +46 -0
- package/src/string/pluralize/rules/uncountable.ts +107 -0
- package/src/string/pluralize/types.ts +4 -0
- package/src/string/slugify/index.ts +3 -0
- package/src/string/strip-html-tags.ts +4 -0
- package/src/string/to-int.ts +20 -0
- package/src/string/to-sentence-case.ts +6 -0
- package/src/string/trim.ts +11 -0
- package/src/string/truncate.ts +11 -0
- package/tsconfig.json +18 -0
- package/tsconfig.lib.json +36 -0
- package/tsconfig.lib.tsbuildinfo +1 -0
- package/tsconfig.node.json +25 -0
- package/vite.config.ts +77 -0
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
const PLURALIZATION_RULES = [
|
|
2
|
+
[/s?$/i, "s"],
|
|
3
|
+
[/[^\u0000-\u007F]$/, "$0"],
|
|
4
|
+
[/([^aeiou]ese)$/i, "$1"],
|
|
5
|
+
[/(ax|test)is$/i, "$1es"],
|
|
6
|
+
[/(alias|[^aou]us|t[lm]as|gas|ris)$/i, "$1es"],
|
|
7
|
+
[/(e[mn]u)s?$/i, "$1s"],
|
|
8
|
+
[/([^l]ias|[aeiou]las|[ejzr]as|[iu]am)$/i, "$1"],
|
|
9
|
+
[
|
|
10
|
+
/(alumn|syllab|vir|radi|nucle|fung|cact|stimul|termin|bacill|foc|uter|loc|strat)(?:us|i)$/i,
|
|
11
|
+
"$1i"
|
|
12
|
+
],
|
|
13
|
+
[/(alumn|alg|vertebr)(?:a|ae)$/i, "$1ae"],
|
|
14
|
+
[/(seraph|cherub)(?:im)?$/i, "$1im"],
|
|
15
|
+
[/(her|at|gr)o$/i, "$1oes"],
|
|
16
|
+
[
|
|
17
|
+
/(agend|addend|millenni|dat|extrem|bacteri|desiderat|strat|candelabr|errat|ov|symposi|curricul|automat|quor)(?:a|um)$/i,
|
|
18
|
+
"$1a"
|
|
19
|
+
],
|
|
20
|
+
[
|
|
21
|
+
/(apheli|hyperbat|periheli|asyndet|noumen|phenomen|criteri|organ|prolegomen|hedr|automat)(?:a|on)$/i,
|
|
22
|
+
"$1a"
|
|
23
|
+
],
|
|
24
|
+
[/sis$/i, "ses"],
|
|
25
|
+
[/(?:(kni|wi|li)fe|(ar|l|ea|eo|oa|hoo)f)$/i, "$1$2ves"],
|
|
26
|
+
[/([^aeiouy]|qu)y$/i, "$1ies"],
|
|
27
|
+
[/([^ch][ieo][ln])ey$/i, "$1ies"],
|
|
28
|
+
[/(x|ch|ss|sh|zz)$/i, "$1es"],
|
|
29
|
+
[/(matr|cod|mur|sil|vert|ind|append)(?:ix|ex)$/i, "$1ices"],
|
|
30
|
+
[/\b((?:tit)?m|l)(?:ice|ouse)$/i, "$1ice"],
|
|
31
|
+
[/(pe)(?:rson|ople)$/i, "$1ople"],
|
|
32
|
+
[/(child)(?:ren)?$/i, "$1ren"],
|
|
33
|
+
[/eaux$/i, "$0"],
|
|
34
|
+
[/m[ae]n$/i, "men"],
|
|
35
|
+
["thou", "you"]
|
|
36
|
+
];
|
|
37
|
+
export {
|
|
38
|
+
PLURALIZATION_RULES
|
|
39
|
+
};
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
const SINGULARIZATION_RULES = [
|
|
2
|
+
[/s$/i, ""],
|
|
3
|
+
[/(ss)$/i, "$1"],
|
|
4
|
+
[/(wi|kni|(?:after|half|high|low|mid|non|night|\W|^)li)ves$/i, "$1fe"],
|
|
5
|
+
[/(ar|(?:wo|[ae])l|[eo][ao])ves$/i, "$1f"],
|
|
6
|
+
[/ies$/i, "y"],
|
|
7
|
+
[/(dg|ss|ois|lk|ok|wn|mb|th|ch|ec|oal|is|ck|ix|sser|ts|wb)ies$/i, "$1ie"],
|
|
8
|
+
[
|
|
9
|
+
/\b(l|(?:neck|cross|hog|aun)?t|coll|faer|food|gen|goon|group|hipp|junk|vegg|(?:pork)?p|charl|calor|cut)ies$/i,
|
|
10
|
+
"$1ie"
|
|
11
|
+
],
|
|
12
|
+
[/\b(mon|smil)ies$/i, "$1ey"],
|
|
13
|
+
[/\b((?:tit)?m|l)ice$/i, "$1ouse"],
|
|
14
|
+
[/(seraph|cherub)im$/i, "$1"],
|
|
15
|
+
[
|
|
16
|
+
/(x|ch|ss|sh|zz|tto|go|cho|alias|[^aou]us|t[lm]as|gas|(?:her|at|gr)o|[aeiou]ris)(?:es)?$/i,
|
|
17
|
+
"$1"
|
|
18
|
+
],
|
|
19
|
+
[
|
|
20
|
+
/(analy|diagno|parenthe|progno|synop|the|empha|cri|ne)(?:sis|ses)$/i,
|
|
21
|
+
"$1sis"
|
|
22
|
+
],
|
|
23
|
+
[/(movie|twelve|abuse|e[mn]u)s$/i, "$1"],
|
|
24
|
+
[/(test)(?:is|es)$/i, "$1is"],
|
|
25
|
+
[
|
|
26
|
+
/(alumn|syllab|vir|radi|nucle|fung|cact|stimul|termin|bacill|foc|uter|loc|strat)(?:us|i)$/i,
|
|
27
|
+
"$1us"
|
|
28
|
+
],
|
|
29
|
+
[
|
|
30
|
+
/(agend|addend|millenni|dat|extrem|bacteri|desiderat|strat|candelabr|errat|ov|symposi|curricul|quor)a$/i,
|
|
31
|
+
"$1um"
|
|
32
|
+
],
|
|
33
|
+
[
|
|
34
|
+
/(apheli|hyperbat|periheli|asyndet|noumen|phenomen|criteri|organ|prolegomen|hedr|automat)a$/i,
|
|
35
|
+
"$1on"
|
|
36
|
+
],
|
|
37
|
+
[/(alumn|alg|vertebr)ae$/i, "$1a"],
|
|
38
|
+
[/(cod|mur|sil|vert|ind)ices$/i, "$1ex"],
|
|
39
|
+
[/(matr|append)ices$/i, "$1ix"],
|
|
40
|
+
[/(pe)(rson|ople)$/i, "$1rson"],
|
|
41
|
+
[/(child)ren$/i, "$1"],
|
|
42
|
+
[/(eau)x?$/i, "$1"],
|
|
43
|
+
[/men$/i, "man"]
|
|
44
|
+
];
|
|
45
|
+
export {
|
|
46
|
+
SINGULARIZATION_RULES
|
|
47
|
+
};
|
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
const UNCOUNTABLE_WORDS = [
|
|
2
|
+
// Singular words with no plurals.
|
|
3
|
+
"adulthood",
|
|
4
|
+
"advice",
|
|
5
|
+
"agenda",
|
|
6
|
+
"aid",
|
|
7
|
+
"aircraft",
|
|
8
|
+
"alcohol",
|
|
9
|
+
"ammo",
|
|
10
|
+
"analytics",
|
|
11
|
+
"anime",
|
|
12
|
+
"athletics",
|
|
13
|
+
"audio",
|
|
14
|
+
"bison",
|
|
15
|
+
"blood",
|
|
16
|
+
"bream",
|
|
17
|
+
"buffalo",
|
|
18
|
+
"butter",
|
|
19
|
+
"carp",
|
|
20
|
+
"cash",
|
|
21
|
+
"chassis",
|
|
22
|
+
"chess",
|
|
23
|
+
"clothing",
|
|
24
|
+
"cod",
|
|
25
|
+
"commerce",
|
|
26
|
+
"cooperation",
|
|
27
|
+
"corps",
|
|
28
|
+
"debris",
|
|
29
|
+
"diabetes",
|
|
30
|
+
"digestion",
|
|
31
|
+
"elk",
|
|
32
|
+
"energy",
|
|
33
|
+
"equipment",
|
|
34
|
+
"excretion",
|
|
35
|
+
"expertise",
|
|
36
|
+
"firmware",
|
|
37
|
+
"flounder",
|
|
38
|
+
"fun",
|
|
39
|
+
"gallows",
|
|
40
|
+
"garbage",
|
|
41
|
+
"graffiti",
|
|
42
|
+
"hardware",
|
|
43
|
+
"headquarters",
|
|
44
|
+
"health",
|
|
45
|
+
"herpes",
|
|
46
|
+
"highjinks",
|
|
47
|
+
"homework",
|
|
48
|
+
"housework",
|
|
49
|
+
"information",
|
|
50
|
+
"jeans",
|
|
51
|
+
"justice",
|
|
52
|
+
"kudos",
|
|
53
|
+
"labour",
|
|
54
|
+
"literature",
|
|
55
|
+
"machinery",
|
|
56
|
+
"mackerel",
|
|
57
|
+
"mail",
|
|
58
|
+
"media",
|
|
59
|
+
"mews",
|
|
60
|
+
"moose",
|
|
61
|
+
"music",
|
|
62
|
+
"mud",
|
|
63
|
+
"manga",
|
|
64
|
+
"news",
|
|
65
|
+
"only",
|
|
66
|
+
"personnel",
|
|
67
|
+
"pike",
|
|
68
|
+
"plankton",
|
|
69
|
+
"pliers",
|
|
70
|
+
"police",
|
|
71
|
+
"pollution",
|
|
72
|
+
"premises",
|
|
73
|
+
"rain",
|
|
74
|
+
"research",
|
|
75
|
+
"rice",
|
|
76
|
+
"salmon",
|
|
77
|
+
"scissors",
|
|
78
|
+
"series",
|
|
79
|
+
"sewage",
|
|
80
|
+
"shambles",
|
|
81
|
+
"shrimp",
|
|
82
|
+
"software",
|
|
83
|
+
"staff",
|
|
84
|
+
"swine",
|
|
85
|
+
"tennis",
|
|
86
|
+
"traffic",
|
|
87
|
+
"transportation",
|
|
88
|
+
"trout",
|
|
89
|
+
"tuna",
|
|
90
|
+
"wealth",
|
|
91
|
+
"welfare",
|
|
92
|
+
"whiting",
|
|
93
|
+
"wildebeest",
|
|
94
|
+
"wildlife",
|
|
95
|
+
"you",
|
|
96
|
+
/pok[eé]mon$/i,
|
|
97
|
+
// Regexes.
|
|
98
|
+
/[^aeiou]ese$/i,
|
|
99
|
+
// "chinese", "japanese"
|
|
100
|
+
/deer$/i,
|
|
101
|
+
// "deer", "reindeer"
|
|
102
|
+
/fish$/i,
|
|
103
|
+
// "fish", "blowfish", "angelfish"
|
|
104
|
+
/measles$/i,
|
|
105
|
+
/o[iu]s$/i,
|
|
106
|
+
// "carnivorous"
|
|
107
|
+
/pox$/i,
|
|
108
|
+
// "chickpox", "smallpox"
|
|
109
|
+
/sheep$/i
|
|
110
|
+
];
|
|
111
|
+
export {
|
|
112
|
+
UNCOUNTABLE_WORDS
|
|
113
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const slugify: (text: string) => string;
|