UNPKG

zip-iterator

Version:

Extract contents from zip archive type using an iterator API using streams or paths. Use stream interface and pipe transforms to add decompression algorithms

16 lines (15 loc) 345 B
import oo from 'on-one'; export default function streamToString(stream, callback) { let string = ''; stream.on('data', (chunk)=>{ string += chunk.toString(); }); oo(stream, [ 'error', 'end', 'close', 'finish' ], (err)=>{ err ? callback(err) : callback(null, string); }); }