lib/tessel/tessel.js
function Tessel(connection) {
  if (connection === undefined) {
    throw new Error('Cannot create a Tessel with an undefined connection type');
  }

  this.usbConnection = undefined;
  this.lanConnection = undefined;
  this.lanPrefer = false;

  this.close = () => {
    // If this tessel has been closed already
    if (this.closed) {
      // Just resolve
      return Promise.resolve();
      // Otherwise
    } else {
      // Mark as having been closed
      this.closed = true;
    }

    // Kill all of this Tessel's remote processes
    return this.connection.end();
  };

  this.addConnection = (connection) => {
    // Set the connection var so we have an abstract interface to relay comms
    switch (connection.connectionType) {
      case 'USB':
        connection.authorized = true;
        this.usbConnection = connection;
        break;
      case 'LAN':
        this.lanConnection = connection;
        break;
      default:
        throw new Error('Invalid connection provided! Must be USB or LAN.');
    }
  };

  this.setLANConnectionPreference = (preferLan) => {
    this.lanPrefer = preferLan;
  };

  // Add this physical connection to the Tessel
  this.addConnection(connection);
  // The human readable name of the device
  this.name = undefined;
  // The unique serial number of the device
  this.serialNumber = undefined;
  // Whether or not this connection has been ended
  this.closed = false;
}
function Tessel(connection) {
  if (connection === undefined) {
    throw new Error('Cannot create a Tessel with an undefined connection type');
  }

  this.usbConnection = undefined;
  this.lanConnection = undefined;
  this.lanPrefer = false;

  this.close = () => {
    // If this tessel has been closed already
    if (this.closed) {
      // Just resolve
      return Promise.resolve();
      // Otherwise
    } else {
      // Mark as having been closed
      this.closed = true;
    }

    // Kill all of this Tessel's remote processes
    return this.connection.end();
  };

  this.addConnection = (connection) => {
    // Set the connection var so we have an abstract interface to relay comms
    switch (connection.connectionType) {
      case 'USB':
        connection.authorized = true;
        this.usbConnection = connection;
        break;
      case 'LAN':
        this.lanConnection = connection;
        break;
      default:
        throw new Error('Invalid connection provided! Must be USB or LAN.');
    }
  };

  this.setLANConnectionPreference = (preferLan) => {
    this.lanPrefer = preferLan;
  };

  // Add this physical connection to the Tessel
  this.addConnection(connection);
  // The human readable name of the device
  this.name = undefined;
  // The unique serial number of the device
  this.serialNumber = undefined;
  // Whether or not this connection has been ended
  this.closed = false;
}
/*
Constructor function for Tessel objects
param connection: the Connection object that represents the physical comm bus