title: How can I listen to an event inside a custom Readable stream in NodeJS?
body: <p>This is my code : </p>
  
  <pre><code>class Counter extends Readable {
      constructor() {
          super();
      }
      _read () { 
          readStream.on('data', (data) =&gt; {
              console.log(JSON.stringify(data));
              this.push(JSON.stringify(data));
          });
          readStream.on('end', () =&gt; {
              this.push(null);
          });
      }
  }
  </code></pre>
  
  <p>I am getting this error and the processing also becomes very slow. </p>
  
  <pre><code>(node:18488) MaxListenersExceededWarning: Possible EventEmitter memory 
  leak detected. 11 end listeners added. Use emitter.setMaxListeners() 
  to increase limit (node:18488) MaxListenersExceededWarning: Possible 
  EventEmitter memory leak detected. 11 data listeners added. Use 
  emitter.setMaxListeners() to increase limit
  </code></pre>
  
  <p>This is my full code. Basically, I want to read a CSV. Convert it into JSON and write to a file. I want to do this operation using stream. I am using 'csv-parser' npm module </p>
  
  <pre><code>const  fs = require('fs');
  var Readable = require('stream').Readable; 
  const csv = require('csv-parser');
  
  
  class Counter extends Readable {
     constructor() {
         super();
     }
     _read () { 
         readStream.on('data', (data) =&gt; {
             console.log(JSON.stringify(data));
             this.push(JSON.stringify(data));
         });
         readStream.on('end', () =&gt; {
             this.push(null);
         });
     }
  }
  let writeStream = fs.createWriteStream('tmp1');
  let readStream = fs.createReadStream('tmp.csv').pipe(csv());
  var counter = new Counter(); 
  counter.pipe(writeStream); 
  </code></pre>