aboutsummaryrefslogtreecommitdiff
path: root/lib/render.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/render.js
parent72e77600465d68edfe3b23abc3509ed1a76a11e4 (diff)
downloadpatchfoo-da132772a40f9291abbc5fd997591e32d9f65268.tar.gz
patchfoo-da132772a40f9291abbc5fd997591e32d9f65268.zip
Move truncate function into utils
Diffstat (limited to 'lib/render.js')
-rw-r--r--lib/render.js7
1 files changed, 1 insertions, 6 deletions
diff --git a/lib/render.js b/lib/render.js
index b4ca804..0e2f95f 100644
--- a/lib/render.js
+++ b/lib/render.js
@@ -419,18 +419,13 @@ Render.prototype.getName = function (id, cb) {
}
}
-function truncate(str, len) {
- str = String(str)
- return str.length > len ? str.substr(0, len) + '...' : str
-}
-
Render.prototype.getNameLink = function (id, opts, cb) {
if (!cb && typeof opts === 'function') cb = opts, opts = null
var length = opts && opts.length || Infinity
var self = this
self.getName(id, function (err, name) {
if (err) return cb(err)
- cb(null, h('a', {href: self.toUrl(id)}, truncate(name, length)))
+ cb(null, h('a', {href: self.toUrl(id)}, u.truncate(name, length)))
})
}