From f104723fe4fe0598f19ac3dacfaacfda93374f7e Mon Sep 17 00:00:00 2001 From: cel Date: Sat, 18 Feb 2017 22:59:38 -0500 Subject: Implement uploading blobs in composer --- lib/util.js | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) (limited to 'lib/util.js') 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 + } +} -- cgit v1.2.3