<commit_before>var fs     = require('fs'),
    path   = require('path'),
    util   = require('util'),
    EventEmitter = require('events').EventEmitter;

// Constants
var PATH     = '/sys/class/gpio',
    PIN_MAP  = {
        // RPi to BCM
        '1':  null,
        '2':  null,
        '3':  0,
        '4':  null,
        '5':  1,
        '6':  null,
        '7':  4,
        '8':  14,
        '9':  null,
        '10': 15,
        '11': 17,
        '12': 18,
        '13': 21,
        '14': null,
        '15': 22,
        '16': 23,
        '17': null,
        '18': 24,
        '19': 10,
        '20': null,
        '21': 9,
        '22': 25,
        '23': 11,
        '24': 8,
        '25': null,
        '26': 7
    },
    MODE_RPI = 'rpi',
    MODE_BCM = 'bcm',
    DIR_IN   = 'in',
    DIR_OUT  = 'out';

var _write = function(path, value, cb) {
    fs.writeFile(path, value, cb);
}

// Keep track of mode and exported pins
var activeMode = MODE_RPI;
var exportedPins = [];

// Constructor
function Gpio() { }
Gpio.prototype = Object.create(EventEmitter.prototype);

// Expose these constants
Gpio.prototype.MODE_RPI = MODE_RPI;
Gpio.prototype.MODE_BCM = MODE_BCM;
Gpio.prototype.DIR_IN   = DIR_IN;
Gpio.prototype.DIR_OUT  = DIR_OUT;

/**
 * Set pin reference mode. Defaults to 'rpi'.
 *
 * @param {string} mode Pin reference mode, 'rpi' or 'bcm'
 */
Gpio.prototype.setMode = function(mode) {
    if (mode !== MODE_RPI && mode !== MODE_BCM) {
        throw new Error('Cannot set invalid mode [' + mode + ']');
    }
    activeMode = mode;
}

/**
 * Setup a channel for use as an input or output
 *
 * @param {number}   channel   Reference to the pin in the current mode's schema<commit_msg>Use proper inheritance function<commit_after>var fs     = require('fs'),
    path   = require('path'),
    util   = require('util'),
    EventEmitter = require('events').EventEmitter;

// Constants
var PATH     = '/sys/class/gpio',
    PIN_MAP  = {
        // RPi to BCM
        '1':  null,
        '2':  null,
        '3':  0,
        '4':  null,
        '5':  1,
        '6':  null,
        '7':  4,
        '8':  14,
        '9':  null,
        '10': 15,
        '11': 17,
        '12': 18,
        '13': 21,
        '14': null,
        '15': 22,
        '16': 23,
        '17': null,
        '18': 24,
        '19': 10,
        '20': null,
        '21': 9,
        '22': 25,
        '23': 11,
        '24': 8,
        '25': null,
        '26': 7
    },
    MODE_RPI = 'rpi',
    MODE_BCM = 'bcm',
    DIR_IN   = 'in',
    DIR_OUT  = 'out';

var _write = function(path, value, cb) {
    fs.writeFile(path, value, cb);
}

// Keep track of mode and exported pins
var activeMode = MODE_RPI;
var exportedPins = [];

// Constructor
function Gpio() { EventEmitter.call(this); }
util.inherits(Gpio, EventEmitter);

// Expose these constants
Gpio.prototype.MODE_RPI = MODE_RPI;
Gpio.prototype.MODE_BCM = MODE_BCM;
Gpio.prototype.DIR_IN   = DIR_IN;
Gpio.prototype.DIR_OUT  = DIR_OUT;

/**
 * Set pin reference mode. Defaults to 'rpi'.
 *
 * @param {string} mode Pin reference mode, 'rpi' or 'bcm'
 */
Gpio.prototype.setMode = function(mode) {
    if (mode !== MODE_RPI && mode !== MODE_BCM) {
        throw new Error('Cannot set invalid mode [' + mode + ']');
    }
    activeMode = mode;
}

/**
 * Setup a channel for use as an input or output
 *
 * @param {number}   channel   Reference to the pin in the current mode's schema
{'fraction_non_alphanumeric': 0.16189362945645822, 'fraction_numerical': 0.04149620105201637, 'mean_word_length': 1.9791122715404699, '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': '5948511', 'n_tokens_mistral': 1341, 'n_tokens_neox': 1258, 'n_words': 337}