<commit_before>'use strict';

class Relay16 {

  constructor() {
    const USB_VID = 0x0416;
    const USB_PID = 0x5020;
    const HID = require('node-hid');

    // Generated by mapRelays()
    this.relayBitmap = [128, 256, 64, 512, 32, 1024, 16, 2048, 8, 4096, 4, 8192, 2, 16384, 1, 32768];

    console.log('Detected devices:', HID.devices(USB_VID, USB_PID));
    this.hid = new HID.HID(USB_VID, USB_PID);
  }

  set(id, state) {
    if (typeof id !== 'number') {
      throw new Error(`Invalid relay ID type: ${id}`);
    }
    if (id < 0 || id > 15) {
      throw new Error(`Invalid relay ID: ${id}`);
    }
    if (typeof state !== 'boolean') {
      throw new Error(`Invalid state: ${state}`);
    }

    return this.read()
    .then((readmask) => {
      let bit = Math.pow(2, id);

      // Map the read mask into the write mask
      let mask = 0;
      for (let i = 0; i < 16; i++) {
        if (readmask & this.relayBitmap[i]) {
          mask = mask | Math.pow(2, i);
        }
      }

      if (state) {<commit_msg>Add close<commit_after>'use strict';

class Relay16 {

  constructor() {
    const USB_VID = 0x0416;
    const USB_PID = 0x5020;
    const HID = require('node-hid');

    // Generated by mapRelays()
    this.relayBitmap = [128, 256, 64, 512, 32, 1024, 16, 2048, 8, 4096, 4, 8192, 2, 16384, 1, 32768];

    console.log('Detected devices:', HID.devices(USB_VID, USB_PID));
    this.hid = new HID.HID(USB_VID, USB_PID);
  }

  close() {
    this.hid.close();
  }

  set(id, state) {
    if (typeof id !== 'number') {
      throw new Error(`Invalid relay ID type: ${typeof id}`);
    }
    if (id < 0 || id > 15) {
      throw new Error(`Invalid relay ID: ${id}`);
    }
    if (typeof state !== 'boolean') {
      throw new Error(`Invalid state: ${state}`);
    }

    return this.read()
    .then((readmask) => {
      let bit = Math.pow(2, id);

      // Map the read mask into the write mask
      let mask = 0;
      for (let i = 0; i < 16; i++) {
        if (readmask & this.relayBitmap[i]) {
          mask = mask | Math.pow(2, i);
        }
      }

      if (state) {
{'fraction_non_alphanumeric': 0.16603235014272122, 'fraction_numerical': 0.06279733587059944, 'mean_word_length': 2.265527950310559, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 7, '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': '6280399', 'n_tokens_mistral': 878, 'n_tokens_neox': 763, 'n_words': 222}