aboutsummaryrefslogtreecommitdiff
path: root/lib/util.js
diff options
context:
space:
mode:
authorcel <cel@f/6sQ6d2CMxRUhLpspgGIulDxDCwYD7DzFzPNr7u5AU=.ed25519>2017-02-18 22:59:38 -0500
committercel <cel@f/6sQ6d2CMxRUhLpspgGIulDxDCwYD7DzFzPNr7u5AU=.ed25519>2017-02-18 22:59:38 -0500
commitf104723fe4fe0598f19ac3dacfaacfda93374f7e (patch)
tree011e2370e9f98fe42875916b66f18f9515818a68 /lib/util.js
parentdba6b897c1d2a7f45b594f74ee428671fc238476 (diff)
downloadpatchfoo-f104723fe4fe0598f19ac3dacfaacfda93374f7e.tar.gz
patchfoo-f104723fe4fe0598f19ac3dacfaacfda93374f7e.zip
Implement uploading blobs in composer
Diffstat (limited to 'lib/util.js')
-rw-r--r--lib/util.js17
1 files changed, 17 insertions, 0 deletions
diff --git a/lib/util.js b/lib/util.js
index d6c3133..fe7a335 100644
--- a/lib/util.js
+++ b/lib/util.js
@@ -78,3 +78,20 @@ u.renderError = function(err) {
h('h3', err.name),
h('pre', err.stack))
}
+
+u.pullLength = function (cb) {
+ var len = 0
+ return pull.through(function (data) {
+ len += data.length
+ }, function (err) {
+ cb(err, len)
+ })
+}
+
+u.tryDecodeJSON = function (json) {
+ try {
+ return JSON.parse(json)
+ } catch(e) {
+ return null
+ }
+}