<commit_before>'use strict';
const usb   = require('usb');

/**
 * [function USB]
 * @param  {[type]} vid [description]
 * @param  {[type]} pid [description]
 * @return {[type]}     [description]
 */
function USB(vid, pid){
  this.device = usb.findByIds(vid, pid);
  return this;
};
/**
 * [open description]
 * @return {[type]} [description]
 */
USB.prototype.open = function () {
  var self = this;
  this.device.open();
  this.device.interfaces.forEach(function(iface){
    iface.claim();
    if(iface.isKernelDriverActive()){
      try{
        iface.detachKernelDriver();
      }catch(e){
        console.error("[ERROR] Could not detatch kernel driver: %s", e)
      }
    }
    iface.endpoints.filter(function(endpoint){
      if(endpoint.direction == 'out'){
        self.endpoint = endpoint;
      }
    });
  });
  return this;
};
/**
 * [function write]
 * @param  {[type]} data [description]
 * @return {[type]}      [description]
 */
USB.prototype.write = function(data, callback){
  this.endpoint.transfer(data);
};

module.exports = USB;
<commit_msg>fix #5<commit_after>'use strict';
const usb   = require('usb');

/**
 * [function USB]
 * @param  {[type]} vid [description]
 * @param  {[type]} pid [description]
 * @return {[type]}     [description]
 */
function USB(vid, pid){
  this.device = usb.findByIds(vid, pid);
  return this;
};
/**
 * [open description]
 * @return {[type]} [description]
 */
USB.prototype.open = function () {
  var self = this;
  this.device.open();
  this.device.interfaces.forEach(function(iface){
    if(iface.isKernelDriverActive()){
      try{
        iface.detachKernelDriver();
      }catch(e){
        console.error("[ERROR] Could not detatch kernel driver: %s", e)
      }
    }
    iface.claim();
    iface.endpoints.filter(function(endpoint){
      if(endpoint.direction == 'out'){
        self.endpoint = endpoint;
      }
    });
  });
  return this;
};
/**
 * [function write]
 * @param  {[type]} data [description]
 * @return {[type]}      [description]
 */
USB.prototype.write = function(data, callback){
  this.endpoint.transfer(data);
};

module.exports = USB;

{'fraction_non_alphanumeric': 0.18246110325318246, 'fraction_numerical': 0.0004714757190004715, 'mean_word_length': 3.1936758893280635, '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': '1248662', 'n_tokens_mistral': 695, 'n_tokens_neox': 694, 'n_words': 147}