diff options
author | cel <cel@f/6sQ6d2CMxRUhLpspgGIulDxDCwYD7DzFzPNr7u5AU=.ed25519> | 2017-02-18 22:59:38 -0500 |
---|---|---|
committer | cel <cel@f/6sQ6d2CMxRUhLpspgGIulDxDCwYD7DzFzPNr7u5AU=.ed25519> | 2017-02-18 22:59:38 -0500 |
commit | f104723fe4fe0598f19ac3dacfaacfda93374f7e (patch) | |
tree | 011e2370e9f98fe42875916b66f18f9515818a68 /lib/util.js | |
parent | dba6b897c1d2a7f45b594f74ee428671fc238476 (diff) | |
download | patchfoo-f104723fe4fe0598f19ac3dacfaacfda93374f7e.tar.gz patchfoo-f104723fe4fe0598f19ac3dacfaacfda93374f7e.zip |
Implement uploading blobs in composer
Diffstat (limited to 'lib/util.js')
-rw-r--r-- | lib/util.js | 17 |
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 + } +} |