I have this code:
"use strict";
var fs = require("fs");
var stream = require('readable-stream');
var Transform = require('stream').Transform,
util = require('util');
var TransformStream = function() {
Transform.call(this, {objectMode: true});
};
util.inherits(TransformStream, Transform);
TransformStream.prototype._transform = function(chunk, encoding, callback) {
if(this.push(chunk)) {
console.log("push returned true");
} else {
console.log("push returned false");
}
callback();
};
var inStream = fs.createReadStream("in.json");
var outStream = fs.createWriteStream("out.json");
var transform = new TransformStream();
inStream.pipe(transform).pipe(outStream);
in.json is 88679467 bytes in size. The first 144 writes state that push returned true. The remaining writes (1210 of them) all state that push returned false.
out.json ends up being a full copy of in.json - so no bytes were dropped.
Which leaves me with no clue about what to do with the return value of push.
What is the right thing to do?