UNPKG

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