@beenotung/tslib
Version:
utils library in Typescript
27 lines (26 loc) • 668 B
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.isEngChar = isEngChar;
exports.to_plural = to_plural;
function isEngChar(c) {
return ('a' <= c && c <= 'z') || ('A' <= c && c <= 'Z');
}
function to_plural(word) {
if (word.endsWith('y')) {
switch (word[word.length - 1 - 1]) {
case 'a':
case 'e':
case 'i':
case 'o':
case 'u':
break;
default:
return word.replace(/y$/, 'ies');
}
}
if (isEngChar(word[word.length - 1])) {
return word + 's';
}
// non-english word
return word;
}