1const { Transform } = require('node:stream'); 2 3const customReporter = new Transform({ 4 writableObjectMode: true, 5 transform(event, encoding, callback) { 6 this.counters ??= {}; 7 this.counters[event.type] = (this.counters[event.type] ?? 0) + 1; 8 callback(); 9 }, 10 flush(callback) { 11 this.push('custom.cjs ') 12 this.push(JSON.stringify(this.counters)); 13 callback(); 14 } 15}); 16 17module.exports = customReporter; 18