UNPKG

choo-shortcache

Version:

choo nanocomponent cache shortcut

15 lines (14 loc) 305 B
module.exports = function (stream, cb) { var chunks = [] stream.on('data', function (chunk) { chunks.push(chunk) }) stream.once('end', function () { if (cb) cb(null, Buffer.concat(chunks)) cb = null }) stream.once('error', function (err) { if (cb) cb(err) cb = null }) }