aboutsummaryrefslogtreecommitdiff
path: root/lib/util.js
diff options
context:
space:
mode:
authorcel <cel@f/6sQ6d2CMxRUhLpspgGIulDxDCwYD7DzFzPNr7u5AU=.ed25519>2019-02-03 14:58:04 -1000
committercel <cel@f/6sQ6d2CMxRUhLpspgGIulDxDCwYD7DzFzPNr7u5AU=.ed25519>2019-02-03 14:58:04 -1000
commitda132772a40f9291abbc5fd997591e32d9f65268 (patch)
treef86be0097dd74ad8e1a240a7324da1f63a7e6745 /lib/util.js
parent72e77600465d68edfe3b23abc3509ed1a76a11e4 (diff)
downloadpatchfoo-da132772a40f9291abbc5fd997591e32d9f65268.tar.gz
patchfoo-da132772a40f9291abbc5fd997591e32d9f65268.zip
Move truncate function into utils
Diffstat (limited to 'lib/util.js')
-rw-r--r--lib/util.js5
1 files changed, 5 insertions, 0 deletions
diff --git a/lib/util.js b/lib/util.js
index 5bd5f11..4fdbc24 100644
--- a/lib/util.js
+++ b/lib/util.js
@@ -261,3 +261,8 @@ u.estimateMessageSize = function (content) {
return JSON.stringify(draftMsg, null, 2).length
}
+
+u.truncate = function (str, len) {
+ str = String(str)
+ return str.length > len ? str.substr(0, len) + '...' : str
+}