shorten in Util

This commit is contained in:
Daniel Odendahl Jr
2017-08-22 21:01:08 +00:00
parent 05e45fbb79
commit 1938b65786
14 changed files with 31 additions and 22 deletions
+4
View File
@@ -75,6 +75,10 @@ class Util {
static list(arr, conj = 'and') {
return `${arr.slice(0, -1).join(', ')}${arr.length > 1 ? `${arr.length > 2 ? ',' : ''} ${conj} ` : ''}${arr.slice(-1)}`; // eslint-disable-line max-len
}
static shorten(text, maxLen = 2000) {
return text.length > maxLen ? `${text.substr(0, maxLen - 3)}...` : text;
}
}
module.exports = Util;