main
Last change
on this file was d24f17c, checked in by Aleksandar Panovski <apano77@…>, 15 months ago |
Initial commit
|
-
Property mode
set to
100644
|
File size:
495 bytes
|
Rev | Line | |
---|
[d24f17c] | 1 | 'use strict'
|
---|
| 2 |
|
---|
| 3 | const singulars = {
|
---|
| 4 | pronoun: 'it',
|
---|
| 5 | is: 'is',
|
---|
| 6 | was: 'was',
|
---|
| 7 | this: 'this'
|
---|
| 8 | }
|
---|
| 9 |
|
---|
| 10 | const plurals = {
|
---|
| 11 | pronoun: 'they',
|
---|
| 12 | is: 'are',
|
---|
| 13 | was: 'were',
|
---|
| 14 | this: 'these'
|
---|
| 15 | }
|
---|
| 16 |
|
---|
| 17 | module.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 | }
|
---|
Note:
See
TracBrowser
for help on using the repository browser.