JS: add Util::pluralize, also add tests for Util::capitalize

This commit is contained in:
Esben Sparre Andreasen
2018-10-11 13:44:38 +02:00
parent 3af91d5d0a
commit c65bc5cc90
6 changed files with 22 additions and 0 deletions

View File

@@ -11,3 +11,16 @@ bindingset[s]
string capitalize(string s) {
result = s.charAt(0).toUpperCase() + s.suffix(1)
}
/**
* Gets the pluralization for `n` occurrences of `noun`.
*
* For example, the pluralization of `"function"` for `n = 2` is `"functions"`.
*/
bindingset[noun, n]
string pluralize(string noun, int n) {
if n = 1 then
result = noun
else
result = noun + "s"
}