<commit_before>var Sensor = require("../lib/sensor.js"),
  util = require("util");

var Devices = {
  GP2Y0A21YK: {
    // https://www.sparkfun.com/products/242
    cm: {
      get: function() {
        return +(12343.85 * Math.pow(this.raw, -1.15)).toFixed(2);
      }
    }
  },
  GP2D120XJ00F: {
    // https://www.sparkfun.com/products/8959
    cm: {
      get: function() {
        return +((2914 / (this.raw + 5)) - 1).toFixed(2);
      }
    }
  },
  GP2Y0A02YK0F: {
    // https://www.sparkfun.com/products/8958
    cm: {
      get: function() {
        return +(10650.08 * Math.pow(this.raw, -0.935) - 10).toFixed(2);
      }
    }
  }
};

// Otherwise known as...
Devices["2Y0A21"] = Devices.GP2Y0A21YK;
Devices["2D120X"] = Devices.GP2D120XJ00F;
Devices["2Y0A02"] = Devices.GP2Y0A02YK0F;

function Distance(opts) {

  if (!(this instanceof Distance)) {
    return new Distance(opts);
  }

  Sensor.call(this, opts);

  var device = Devices[opts.device];

  if (device) {
    if (!device.inches) {
      device.inches = {
        get: function() {
          return +(this.cm * 0.39).toFixed(2);
        }
      };
    }
  } else {
    device = {
      inches: {
        value: null
      },<commit_msg>Allow new device type to be passed as an object<commit_after>var Sensor = require("../lib/sensor.js"),
  util = require("util");

var Devices = {
  GP2Y0A21YK: {
    // https://www.sparkfun.com/products/242
    cm: {
      get: function() {
        return +(12343.85 * Math.pow(this.raw, -1.15)).toFixed(2);
      }
    }
  },
  GP2D120XJ00F: {
    // https://www.sparkfun.com/products/8959
    cm: {
      get: function() {
        return +((2914 / (this.raw + 5)) - 1).toFixed(2);
      }
    }
  },
  GP2Y0A02YK0F: {
    // https://www.sparkfun.com/products/8958
    cm: {
      get: function() {
        return +(10650.08 * Math.pow(this.raw, -0.935) - 10).toFixed(2);
      }
    }
  }
};

// Otherwise known as...
Devices["2Y0A21"] = Devices.GP2Y0A21YK;
Devices["2D120X"] = Devices.GP2D120XJ00F;
Devices["2Y0A02"] = Devices.GP2Y0A02YK0F;

function Distance(opts) {

  if (!(this instanceof Distance)) {
    return new Distance(opts);
  }

  Sensor.call(this, opts);

  var device;
  if (typeof opts.device === "string") {
    device = Devices[opts.device];
  } else {
    device = opts.device;
  }

  if (device) {
    if (!device.inches) {
      device.inches = {
        get: function() {
          return +(this.cm * 0.39).toFixed(2);
        }
      };
    }
  } else {
    device = {
      inches: {
        value: null
      },
{'fraction_non_alphanumeric': 0.1796078431372549, 'fraction_numerical': 0.06980392156862746, 'mean_word_length': 2.095873786407767, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 6, 'lorem ipsum': 0, 'www.': 6, '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': '3167082', 'n_tokens_mistral': 1097, 'n_tokens_neox': 992, 'n_words': 165}