<commit_before>(function(module) {

  var binPath = require('phantomjs').path;
  var execFile = require('child_process').execFile;
  var extend = require('util')._extend;
  var path = require('path');

  var DEFAULT_BUFFER_SIZE = 800*1024;

  /**
   * Run the the parser through phantom.
   */
  module.exports = function(url, options, cb) {
    if (typeof url === 'undefined') {
      throw new Error('Missing url parameter.');
    }

    // Default callback function for handling phantomjs returns.
    var defaultCb = function(err, output) {
      if (err) {
        throw new Error(err);
      }
      return output;
    };

    // Fall back to defaults if no options or callbacks are provided.
    if (typeof options === 'undefined' && typeof cb === 'undefined') {
      cb = defaultCb;
    }
    // Fall back to default options if only callback is provided.
    if (typeof options === 'function') {
      cb = options;
    }

    // Process config options.
    var defaults = {
      width: 1200,
      height: 900,
      excludeSelectors: [],
      enabledOrigins: [],
      keepInlineStyles: false,
      ignoreConsole: true,
      maxBuffer: DEFAULT_BUFFER_SIZE
    };
    var config = extend(defaults, options);

    var childArgs = [
      path.resolve(path.join(__dirname, 'lib', 'runner.js')),
      url,
      config.width,
      config.height,
      JSON.stringify(config.excludeSelectors),
      JSON.stringify(config.enabledOrigins),
      config.keepInlineStyles,
      (config.ignoreConsole) ? '--ignoreConsole' : false
    ];
    var phantomOptions = {
      maxBuffer: config.maxBuffer
    };

    // Call PhantomJS with our runner script.
    execFile(binPath, childArgs, phantomOptions, function(err, stdout, stderr) {
      if (err) {
        console.log('Something is awry with phantomjs...');
        if (stderr) {
          err.message = stderr;
        }
        cb(err, null);
      }
      else {
        cb(null, stdout);
      }
    });
  };

}(typeof module === "object" && typeof module.exports === "object" && module || this));
<commit_msg>Return a method instead of a standalone function<commit_after>(function(exports) {

  var binPath = require('phantomjs').path;
  var execFile = require('child_process').execFile;
  var extend = require('util')._extend;
  var path = require('path');

  var DEFAULT_BUFFER_SIZE = 800*1024;

  /**
   * Run the the parser through phantom.
   */
  exports.generate = function(url, options, cb) {
    if (typeof url === 'undefined') {
      throw new Error('Missing url parameter.');
    }

    // Default callback function for handling phantomjs returns.
    var defaultCb = function(err, output) {
      if (err) {
        throw new Error(err);
      }
      console.log(output);
    };

    // Fall back to defaults if no options or callbacks are provided.
    if (typeof options === 'undefined' && typeof cb === 'undefined') {
      cb = defaultCb;
    }
    // Fall back to default options if only callback is provided.
    if (typeof options === 'function') {
      cb = options;
    }

    // Process config options.
    var defaults = {
      width: 1200,
      height: 900,
      excludeSelectors: [],
      enabledOrigins: [],
      keepInlineStyles: false,
      ignoreConsole: true,
      maxBuffer: DEFAULT_BUFFER_SIZE
    };
    var config = extend(defaults, options);

    var childArgs = [
      path.resolve(path.join(__dirname, 'lib', 'runner.js')),
      url,
      config.width,
      config.height,
      JSON.stringify(config.excludeSelectors),
      JSON.stringify(config.enabledOrigins),
      config.keepInlineStyles,
      (config.ignoreConsole) ? '--ignoreConsole' : false
    ];
    var phantomOptions = {
      maxBuffer: config.maxBuffer
    };

    // Call PhantomJS with our runner script.
    execFile(binPath, childArgs, phantomOptions, function(err, stdout, stderr) {
      if (err) {
        console.log('Something is awry with phantomjs...');
        if (stderr) {
          err.message = stderr;
        }
        cb(err, null);
      }
      else {
        cb(null, stdout);
      }
    });
  };

}(typeof exports === 'object' && exports || this));

{'fraction_non_alphanumeric': 0.1272246272246272, 'fraction_numerical': 0.006734006734006734, 'mean_word_length': 2.4428807947019866, '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': '3986391', 'n_tokens_mistral': 1251, 'n_tokens_neox': 1191, 'n_words': 331}