How to use through2

Comprehensive through2 code examples:

How to use through2.obj:

23
24
25
26
27
28
29
30
31
32
exports.stringify = jsonStream.stringify.bind(jsonStream);
exports.stringify.obj = jsonStream.stringifyObject = function (options) {
  
  options = options || {};
  
  return through.obj(function (chunk, enc, done) {
    
    done(null, JSON.stringify(chunk, null, options.space));
  });
}