UNPKG

917 BJavaScriptView Raw
1"use strict";
2Object.defineProperty(exports, "__esModule", { value: true });
3/**
4 * Returns the plural form of a word.
5 *
6 * @param n The number of things to represent. This dictates whether to return
7 * the singular or plural form of the word.
8 * @param singular The singular form of the word.
9 * @param plural An optional plural form of the word. If non is given, the
10 * plural form is constructed by appending an "s" to the singular form.
11 */
12function pluralize(n, singular, plural) {
13 if (n === 1) {
14 return singular;
15 }
16 if (plural !== undefined) {
17 return plural;
18 }
19 return `${singular}s`;
20}
21exports.pluralize = pluralize;
22/**
23 * Replaces all the instances of [[toReplace]] by [[replacement]] in [[str]].
24 */
25function replaceAll(str, toReplace, replacement) {
26 return str.split(toReplace).join(replacement);
27}
28exports.replaceAll = replaceAll;
29//# sourceMappingURL=strings.js.map
\No newline at end of file