UNPKG

1.52 kBTypeScriptView Raw
1/**
2 * Pluralize or singularize a word based on the passed in count.
3 *
4 * @param word
5 * @param count
6 * @param inclusive
7 */
8declare function pluralize(word: string, count?: number, inclusive?: boolean): string;
9
10declare namespace pluralize {
11 /**
12 * Pluralize a word based.
13 *
14 * @param word
15 */
16 function plural(word: string): string;
17
18 /**
19 * Singularize a word based.
20 *
21 * @param word
22 */
23 function singular(word: string): string;
24
25 /**
26 * Add a pluralization rule to the collection.
27 *
28 * @param rule
29 * @param replacement
30 */
31 function addPluralRule(rule: string | RegExp, replacement: string): void;
32
33 /**
34 * Add a singularization rule to the collection.
35 *
36 * @param rule
37 * @param replacement
38 */
39 function addSingularRule(rule: string | RegExp, replacement: string): void;
40
41 /**
42 * Add an irregular word definition.
43 *
44 * @param single
45 * @param plural
46 */
47 function addIrregularRule(single: string, plural: string): void;
48
49 /**
50 * Add an uncountable word rule.
51 *
52 * @param word
53 */
54 function addUncountableRule(word: string | RegExp): void;
55
56 /**
57 * Test if provided word is plural.
58 *
59 * @param word
60 */
61 function isPlural(word: string): boolean;
62
63 /**
64 * Test if provided word is singular.
65 *
66 * @param word
67 */
68 function isSingular(word: string): boolean;
69}
70
71export = pluralize;
72export as namespace pluralize;