From fadcd865464e84a4bf47c8a58a6ee7892b2f8a9d Mon Sep 17 00:00:00 2001 From: James Bromwell <943160+thw0rted@users.noreply.github.com> Date: Wed, 18 Oct 2017 18:17:51 +0200 Subject: [PATCH] Add new methods from pluralize v5.1.0 (#20683) * Add isPlural / isSingular Test the changes to `index.d.ts`. * Add isPlural / isSingular See [release notes](https://github.com/blakeembrey/pluralize/releases), new API has been present since July. --- types/pluralize/index.d.ts | 16 +++++++++++++++- types/pluralize/pluralize-tests.ts | 8 +++++++- 2 files changed, 22 insertions(+), 2 deletions(-) diff --git a/types/pluralize/index.d.ts b/types/pluralize/index.d.ts index 0a77d87a59..7a11a23839 100644 --- a/types/pluralize/index.d.ts +++ b/types/pluralize/index.d.ts @@ -57,9 +57,23 @@ interface PluralizeStatic { * @param word */ addUncountableRule(word: string|RegExp): void; + + /** + * Test if provided word is plural. + * + * @param word + */ + isPlural(word: string): boolean; + + /** + * Test if provided word is singular. + * + * @param word + */ + isSingular(word: string): boolean; } declare module "pluralize" { export = pluralize; } -declare var pluralize: PluralizeStatic; \ No newline at end of file +declare var pluralize: PluralizeStatic; diff --git a/types/pluralize/pluralize-tests.ts b/types/pluralize/pluralize-tests.ts index 951fe0b91a..16c599aab8 100644 --- a/types/pluralize/pluralize-tests.ts +++ b/types/pluralize/pluralize-tests.ts @@ -22,4 +22,10 @@ pluralize.plural('irregular'); //=> "regular" pluralize.plural('paper'); //=> "papers" pluralize.addUncountableRule('paper'); -pluralize.plural('paper'); //=> "paper" \ No newline at end of file +pluralize.plural('paper'); //=> "paper" + +pluralize.isPlural('test') //=> false +pluralize.isSingular('test') //=> true + +pluralize.isPlural('tests') //=> true +pluralize.isSingular('tests') //=> false