<commit_before>var Readable = require('stream').Readable;
var Writable = require('stream').Writable;
var gutil = require('gulp-util');

// TODO: Rough proof of concept - Send back a first image and some text


function gulpSpritesmith(params) {
  var images = [];
  var image;
  var inputComplete = false;
  // TODO: Relocate writable into class?
  var spriteData = new Writable({
    objectMode: true
  });
  spriteData._write = function (file, encoding, cb) {
    console.log('write', file);
    var filepath = file.path;
    if (filepath) {
      images.push(filepath);
    }
    image = file;
    cb();
  };
  spriteData.on('finish', function () {
    inputComplete = true;
  });

  spriteData.img = new Readable({
    objectMode: true
  });
  spriteData.img._read = function () {
    // If the stream has been finished, otherwise wait for the finish event
    if (inputComplete) {
      process.nextTick(sendResponse);
    } else {
      spriteData.on('finish', sendResponse);
    }

    var that = this;<commit_msg>It looks like a double call is occurring x_x<commit_after>var Readable = require('stream').Readable;
var Writable = require('stream').Writable;
var gutil = require('gulp-util');

// TODO: Rough proof of concept - Send back a first image and some text


function gulpSpritesmith(params) {
  var images = [];
  var image;
  var inputComplete = false;
  // TODO: Relocate writable into class?
  var spriteData = new Writable({
    objectMode: true
  });
  spriteData._write = function (file, encoding, cb) {
    console.log('write', file);
    var filepath = file.path;
    if (filepath) {
      images.push(filepath);
    }
    image = file;
    cb();
  };
  spriteData.on('finish', function () {
    console.log('done');
    inputComplete = true;
  });

  spriteData.img = new Readable({
    objectMode: true
  });
  spriteData.img._read = function () {
    // If the stream has been finished, otherwise wait for the finish event
    console.log('hai', inputComplete);
    if (inputComplete) {
      process.nextTick(sendResponse);
    } else {
      spriteData.on('finish', sendResponse);
    }

    var that = this;
{'fraction_non_alphanumeric': 0.12774918109499298, 'fraction_numerical': 0.0, 'mean_word_length': 3.1274131274131274, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, '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': '3479255', 'n_tokens_mistral': 669, 'n_tokens_neox': 652, 'n_words': 190}