<commit_before>const request = require('request');
const semver = require('semver');

const manager = require('bin-manager');

const BIN_PATH = 'bin';
const LATEST_ENDPOINT = 'https://arduino-cli.github.io/arduino-latest/VERSION';
const MIRRORS = [{
  os: 'win32',
  arch: 'x64',
  uri: 'https://downloads.arduino.cc/arduino-{{version}}-windows.zip',
  bin: 'arduino_debug.exe'
}, {
  os: 'darwin',
  arch: 'x64',
  uri: 'https://downloads.arduino.cc/arduino-{{version}}-macosx.zip',
  bin: 'Contents/MacOS/Arduino'
}, {
  os: 'linux',
  arch: 'x32',
  uri: 'https://downloads.arduino.cc/arduino-{{version}}-linux32.tar.xz',
  bin: 'arduino'
}, {
  os: 'linux',
  arch: 'x64',
  uri: 'https://downloads.arduino.cc/arduino-{{version}}-linux64.tar.xz',
  bin: 'arduino'
}, {
  os: 'linux',
  arch: 'arm',
  uri: 'https://downloads.arduino.cc/arduino-{{version}}-linuxarm.tar.xz',
  bin: 'arduino'
}];

/**
 * Initialize a new `Arduino`
 *
 * @param {String} version
 * @api public
 */

function arduino(version) {
  version = version || 'latest';
  let inited = false;
  const bin = manager(BIN_PATH, 'arduino-' + version);

  /**
   * Runs the arduino binary
   *
   * @param {Array}    argv
   * @param {Function} callback
   * @api public
   */
  function run(argv, callback) {
    if (inited) {
      bin.run(argv, callback);
      return;
    }

    getSanitizedVersion((err, version) => {
      if (err) {
        callback(err);
        return;
      }
      init(version);
      bin.run(argv, callback);
    });
  }

  /**
   * Load/download the current version of the binary
   *
   * @param {Object} opts
   * @param {Function} callback
   * @api public
   */
  function load(opts, callback) {
    if (inited) {
      bin.load(err => callback(err));
      return;
    }

    getSanitizedVersion((err, version) => {
      if (err) {
        callback(err);
        return;
      }
      init(version);
      bin.load(err => callback(err));
    });
  }

  /**
   * Removes the current version of the binary
   *
   * @param  {Object} opts
   * @param  {Function} callback
   * @api public
   */
  function unload(opts, callback) {
    if (inited) {
      bin.unload(opts, err => callback(err));
      return;
    }

    getSanitizedVersion((err, version) => {
      if (err) {
        callback(err);
        return;
      }
      init(version);
      bin.unload(opts, err => callback(err));
    });
  }

  /**
   * Gets the version and the it sanitizes it
   *
   * @param  {Function} callback
   * @api private
   */
  function getSanitizedVersion(callback) {
    getFullVersion((err, version) => {
      if (err) {
        callback(err);
        return;
      }
      version = semver.clean(version);
      callback(null, version);
    });
  }

  /**
   * Gets the right version number when special values are passed as version
   *
   * @param  {Function} callback
   * @api private
   */
  function getFullVersion(callback) {
    if (version !== 'latest') {
      callback(null, version);
      return;
    }
    getLatestVersion(callback);
  }

  /**
   * Retrieves latest arduino ide version available
   *
   * @param  {Function} callback
   * @api private
  */
  function getLatestVersion(callback) {
    request(LATEST_ENDPOINT, (err, res, body) => {
      if (err || res.statusCode !== 200) {
        callback(err || 'error: ' + err.statusCode);
        return;
      }
      callback(null, body);
    });
  }

  /**
   * Initializes the binary mirrors
   *
   * @param {String} version
   * @api private
   */
  function init(version) {
    MIRRORS.forEach(mirror => {
      bin.src(mirror.uri.replace('{{version}}', version), mirror.os, mirror.arch);

      if (mirror.os === process.platform) {
        bin.use(mirror.bin);
      }
    });

    inited = true;
  }

  return {
    run,
    load,
    unload
  };
}

module.exports = arduino;<commit_msg>Add function binary()<commit_after>const request = require('request');
const semver = require('semver');

const manager = require('bin-manager');

const BIN_PATH = 'bin';
const LATEST_ENDPOINT = 'https://arduino-cli.github.io/arduino-latest/VERSION';
const MIRRORS = [{
  os: 'win32',
  arch: 'x64',
  uri: 'https://downloads.arduino.cc/arduino-{{version}}-windows.zip',
  bin: 'arduino_debug.exe'
}, {
  os: 'darwin',
  arch: 'x64',
  uri: 'https://downloads.arduino.cc/arduino-{{version}}-macosx.zip',
  bin: 'Contents/MacOS/Arduino'
}, {
  os: 'linux',
  arch: 'x32',
  uri: 'https://downloads.arduino.cc/arduino-{{version}}-linux32.tar.xz',
  bin: 'arduino'
}, {
  os: 'linux',
  arch: 'x64',
  uri: 'https://downloads.arduino.cc/arduino-{{version}}-linux64.tar.xz',
  bin: 'arduino'
}, {
  os: 'linux',
  arch: 'arm',
  uri: 'https://downloads.arduino.cc/arduino-{{version}}-linuxarm.tar.xz',
  bin: 'arduino'
}];

/**
 * Initialize a new `Arduino`
 *
 * @param {String} version
 * @api public
 */

function arduino(version) {
  version = version || 'latest';
  let inited = false;
  const bin = manager(BIN_PATH, 'arduino-' + version);

  /**
   * Runs the arduino binary
   *
   * @param {Array}    argv
   * @param {Function} callback
   * @api public
   */
  function run(argv, callback) {
    if (inited) {
      bin.run(argv, callback);
      return;
    }

    getSanitizedVersion((err, version) => {
      if (err) {
        callback(err);
        return;
      }
      init(version);
      bin.run(argv, callback);
    });
  }

  /**
   * Load/download the current version of the binary
   *
   * @param {Object} opts
   * @param {Function} callback
   * @api public
   */
  function load(opts, callback) {
    if (inited) {
      bin.load(err => callback(err));
      return;
    }

    getSanitizedVersion((err, version) => {
      if (err) {
        callback(err);
        return;
      }
      init(version);
      bin.load(err => callback(err));
    });
  }

  /**
   * Removes the current version of the binary
   *
   * @param  {Object} opts
   * @param  {Function} callback
   * @api public
   */
  function unload(opts, callback) {
    if (inited) {
      bin.unload(opts, err => callback(err));
      return;
    }

    getSanitizedVersion((err, version) => {
      if (err) {
        callback(err);
        return;
      }
      init(version);
      bin.unload(opts, err => callback(err));
    });
  }

  /**
   * Gets the version and the it sanitizes it
   *
   * @param  {Function} callback
   * @api private
   */
  function getSanitizedVersion(callback) {
    getFullVersion((err, version) => {
      if (err) {
        callback(err);
        return;
      }
      version = semver.clean(version);
      callback(null, version);
    });
  }

  /**
   * Gets the right version number when special values are passed as version
   *
   * @param  {Function} callback
   * @api private
   */
  function getFullVersion(callback) {
    if (version !== 'latest') {
      callback(null, version);
      return;
    }
    getLatestVersion(callback);
  }

  /**
   * Retrieves latest arduino ide version available
   *
   * @param  {Function} callback
   * @api private
  */
  function getLatestVersion(callback) {
    request(LATEST_ENDPOINT, (err, res, body) => {
      if (err || res.statusCode !== 200) {
        callback(err || 'error: ' + err.statusCode);
        return;
      }
      callback(null, body);
    });
  }

  /**
   * Initializes the binary mirrors
   *
   * @param {String} version
   * @api private
   */
  function init(version) {
    MIRRORS.forEach(mirror => {
      bin.src(mirror.uri.replace('{{version}}', version), mirror.os, mirror.arch);

      if (mirror.os === process.platform) {
        bin.use(mirror.bin);
      }
    });

    inited = true;
  }

  /**
   *
   * @api public
   * @returns /path/to/bin
   */
  function binary() {
    return bin.bin();
  }

  return {
    run,
    load,
    unload
  };
}

module.exports = arduino;
{'fraction_non_alphanumeric': 0.16284695696460402, 'fraction_numerical': 0.004329004329004329, 'mean_word_length': 2.4406482698204117, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 23, 'https://': 12, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 12, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1604424', 'n_tokens_mistral': 2797, 'n_tokens_neox': 2712, 'n_words': 569}