diff options
Diffstat (limited to 'lib/util.js')
-rw-r--r-- | lib/util.js | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/lib/util.js b/lib/util.js index 731cc82..c5584ee 100644 --- a/lib/util.js +++ b/lib/util.js @@ -93,6 +93,16 @@ u.toLinkArray = function (x) { return u.toArray(x).map(u.toLink).filter(u.linkDest) } +u.toString = function (str) { + switch (typeof str) { + case 'string': return str + case 'object': + if (str !== null) return JSON.stringify(str) + default: + return String(str) + } +} + u.renderError = function(err) { return h('div.error', h('h3', err.name), |