Move gr-count-string-formatter to typescript

Change-Id: I8bd7d3c4fa9a327da382a02523cead9b2208d04f
This commit is contained in:
Milutin Kristofic
2020-08-03 16:54:21 +02:00
parent 02dc5b67c2
commit fa35dea785

View File

@@ -17,40 +17,28 @@
export const GrCountStringFormatter = {
/**
* Returns a count plus string that is pluralized when necessary.
*
* @param {number} count
* @param {string} noun
* @return {string}
*/
computePluralString(count, noun) {
computePluralString(count: number, noun: string): string {
return this.computeString(count, noun) + (count > 1 ? 's' : '');
},
/**
* Returns a count plus string that is not pluralized.
*
* @param {number} count
* @param {string} noun
* @return {string}
*/
computeString(count, noun) {
computeString(count: number, noun: string): string {
if (count === 0) {
return '';
}
return count + ' ' + noun;
return `${count} ${noun}`;
},
/**
* Returns a count plus arbitrary text.
*
* @param {number} count
* @param {string} text
* @return {string}
*/
computeShortString(count, text) {
computeShortString(count: number, text: string): string {
if (count === 0) {
return '';
}
return count + text;
return `${count}${text}`;
},
};