<commit_before>'use strict';

const h = require('highland');

class Pipeline {
  constructor() {
    this._input = h();
    this._transforms = [];
  }

  apply(obj) {

    /**
     * If we have a curried function then save it as is:
     */

    if (typeof obj === 'function') {
      this._transforms.push(obj);
    }

    /**
     * Otherwise, we let the object itself tell us what to
     * save:
     */

    else {
      this._transforms.push(obj.apply());
    }

    return this;
  }

  run(cb) {
    /**
     * The transforms list is a set of curried functions; use them to
     * a Highland pipeline:
     */

    let pipeline = s => this._transforms.reduce((stream, fn) => fn(stream), s);

    h()
    .through(pipeline)
    .done(cb);
  }
};

module.exports = Pipeline;<commit_msg>check if there is actually a finished callback in Pipeline.run()<commit_after>'use strict';

const h = require('highland');

class Pipeline {
  constructor() {
    this._input = h();
    this._transforms = [];
  }

  apply(obj) {

    /**
     * If we have a curried function then save it as is:
     */

    if (typeof obj === 'function') {
      this._transforms.push(obj);
    }

    /**
     * Otherwise, we let the object itself tell us what to
     * save:
     */

    else {
      this._transforms.push(obj.apply());
    }

    return this;
  }

  run(finished) {

    /**
     * The transforms list is a set of curried functions; use them to
     * a Highland pipeline:
     */

    let pipeline = s => this._transforms.reduce((stream, fn) => fn(stream), s);

    h()
    .through(pipeline)
    .done(() => {
      if (finished) {
        finished()
      }
    })
    ;
  }
};

module.exports = Pipeline;
{'fraction_non_alphanumeric': 0.1436950146627566, 'fraction_numerical': 0.0, 'mean_word_length': 2.08499095840868, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 8, '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': '1264081', 'n_tokens_mistral': 561, 'n_tokens_neox': 540, 'n_words': 153}