aboutsummaryrefslogtreecommitdiff
path: root/lib/util.js
diff options
context:
space:
mode:
authorcel <cel@f/6sQ6d2CMxRUhLpspgGIulDxDCwYD7DzFzPNr7u5AU=.ed25519>2017-05-23 23:24:25 -1000
committercel <cel@f/6sQ6d2CMxRUhLpspgGIulDxDCwYD7DzFzPNr7u5AU=.ed25519>2017-05-23 23:24:25 -1000
commitd10fc1c7fbc410ec0c4773902251255582e33adc (patch)
treeda43af098d4d11b857f17eaad46c1b0050c8f70d /lib/util.js
parent6dbfedff2f7246430f4e6da100bc3baed0ef4ce1 (diff)
downloadpatchfoo-d10fc1c7fbc410ec0c4773902251255582e33adc.tar.gz
patchfoo-d10fc1c7fbc410ec0c4773902251255582e33adc.zip
wip: more git
Diffstat (limited to 'lib/util.js')
-rw-r--r--lib/util.js20
1 files changed, 20 insertions, 0 deletions
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
+ }
+}