<commit_before>
var util = require('util');
var TransformStream = require('stream').Transform;
var sendgrid = require('sendgrid-web');

var SendgridStream = function (options) {
  TransformStream.call(this, { objectMode: true, decodeStrings: false });

  this.email = new sendgrid(options.auth);
  this.to = options.to;
  this.from = options.from || '<EMAIL>';
  this.subject = options.subject || 'notify';

};

util.inherits(SendgridStream, TransformStream);

SendgridStream.prototype._write = function(chunk, encoding, done) {
  var self = this;
  //
  // Expects an object
  //
  var text = JSON.stringify(chunk, null, 2);

  this.email.send({
    to: this.to,
    from: this.from,
    subject: this.subject,
    text: text
  }, function (err) {
    if (err) { return self.emit(err) }
  });

  done();
};

SendgridStream.prototype._read = function (size) {};

module.exports = function(options) {
  return new SendgridStream(options);
}<commit_msg>[fix] make sure to push the data in the underlying buffer to be read from another stream<commit_after>
var util = require('util');
var TransformStream = require('stream').Transform;
var sendgrid = require('sendgrid-web');

var SendgridStream = function (options) {
  TransformStream.call(this, { objectMode: true, decodeStrings: false });

  this.email = new sendgrid(options.auth);
  this.to = options.to;
  this.from = options.from || '<EMAIL>';
  this.subject = options.subject || 'notify';

};

util.inherits(SendgridStream, TransformStream);

SendgridStream.prototype._write = function(chunk, encoding, done) {
  var self = this;
  //
  // Expects an object
  //
  var text = JSON.stringify(chunk, null, 2);

  this.email.send({
    to: this.to,
    from: this.from,
    subject: this.subject,
    text: text
  }, function (err) {
    if (err) { return self.emit(err) }
  });

  this.push(chunk);

  done();
};

SendgridStream.prototype._read = function (size) {};

module.exports = function(options) {
  return new SendgridStream(options);
}
{'fraction_non_alphanumeric': 0.14914914914914915, 'fraction_numerical': 0.001001001001001001, 'mean_word_length': 3.948019801980198, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2662573', 'n_tokens_mistral': 642, 'n_tokens_neox': 624, 'n_words': 159}