localfs.js
function consumeStream(stream, callback) {
    var chunks = [];
    stream.on("data", onData);
    stream.on("end", onEnd);
    stream.on("error", onError);
    function onData(chunk) {
        chunks.push(chunk);
    }
    function onEnd() {
        cleanup();
        callback(null, chunks.join(""));
    }
    function onError(err) {
        cleanup();
        callback(err);
    }
    function cleanup() {
        stream.removeListener("data", onData);
        stream.removeListener("end", onEnd);
        stream.removeListener("error", onError);
    }
}
function consumeStream(stream, callback) {
    var chunks = [];
    stream.on("data", onData);
    stream.on("end", onEnd);
    stream.on("error", onError);
    function onData(chunk) {
        chunks.push(chunk);
    }
    function onEnd() {
        cleanup();
        callback(null, chunks.join(""));
    }
    function onError(err) {
        cleanup();
        callback(err);
    }
    function cleanup() {
        stream.removeListener("data", onData);
        stream.removeListener("end", onEnd);
        stream.removeListener("error", onError);
    }
}
function consumeStream ( stream , callback ) { var chunks = [ ] ; stream . on ( "data" , onData ) ; stream . on ( "end" , onEnd ) ; stream . on ( "error" , onError ) ; function onData ( chunk ) { chunks . push ( chunk ) ; } function onEnd ( ) { cleanup ( ) ; callback ( null , chunks . join ( "" ) ) ; } function onError ( err ) { cleanup ( ) ; callback ( err ) ; } function cleanup ( ) { stream . removeListener ( "data" , onData ) ; stream . removeListener ( "end" , onEnd ) ; stream . removeListener ( "error" , onError ) ; } }
Consume all data in a readable stream and call callback with full buffer.
Consume all data in a readable stream and call callback with full buffer .