From d10fc1c7fbc410ec0c4773902251255582e33adc Mon Sep 17 00:00:00 2001 From: cel Date: Tue, 23 May 2017 23:24:25 -1000 Subject: wip: more git --- lib/util.js | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) (limited to 'lib/util.js') diff --git a/lib/util.js b/lib/util.js index 5546716..dbefa14 100644 --- a/lib/util.js +++ b/lib/util.js @@ -62,6 +62,10 @@ u.hyperwrap = function (fn) { } } +u.toLink = function (link) { + return typeof link === 'string' ? {link: link} : link +} + u.linkDest = function (link) { return typeof link === 'string' ? link : link && link.link || link } @@ -114,3 +118,19 @@ u.isMsgEncrypted = function (msg) { var c = msg && msg.value.content return typeof c === 'string' } + +u.pullConcat = function (cb) { + return pull.collect(function (err, bufs) { + if (err) return cb(err) + cb(null, Buffer.concat(bufs)) + }) +} + +u.customError = function (name) { + return function (message) { + var error = new Error(message) + error.name = name + error.stack = error.stack.replace(/^ at .*\n/m, '') + return error + } +} -- cgit v1.2.3