What is callback in this context? Is it just something you need to call to signal that processing has ended for the chunk, or does it have any further use?
Logging it to the console produces:
function (er, data) {
return afterTransform(stream, er, data);
}
Yes, if you don’t call it, the transform stream will just hang there and block the pipe. As for the er parameter, that’s if something went wrong (error first and all); and then you can pipe some additional data (or simply the data itself). Example:
In fact you’ll sometimes see it called like that. :-) It behaves slightly differently though in that a middleware callback typically directly invokes the next middleware, while the next stream in the pipe will consume the data as soon as we .push() it. Instead, it’s a success (or failure) signal when we’re finished processing the current chunk, and ready (or not) to receive the next one… so omitting the callback in the above example would still pass through the first chunk.