• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1'use strict'
2
3const singulars = {
4  pronoun: 'it',
5  is: 'is',
6  was: 'was',
7  this: 'this'
8}
9
10const plurals = {
11  pronoun: 'they',
12  is: 'are',
13  was: 'were',
14  this: 'these'
15}
16
17module.exports = class Pluralizer {
18  constructor (singular, plural) {
19    this.singular = singular
20    this.plural = plural
21  }
22
23  pluralize (count) {
24    const one = count === 1
25    const keys = one ? singulars : plurals
26    const noun = one ? this.singular : this.plural
27    return { ...keys, count, noun }
28  }
29}
30