lib/find.js
function findById (id) {
  return new Promise(async (resolve, reject) => {
    try {
      if (!id || !id.length) {
        throw new Error('Undefined parameter id!');
      }

      const ports = await this.find();
      const result = ports.filter(port => port.info.includes(id));

      if (!result.length) {
        resolve(null);
      } else {
        resolve(result[0]);
      }
    } catch (error) {
      reject(error);
    }
  });
}
function findById (id) {
  return new Promise(async (resolve, reject) => {
    try {
      if (!id || !id.length) {
        throw new Error('Undefined parameter id!');
      }

      const ports = await this.find();
      const result = ports.filter(port => port.info.includes(id));

      if (!result.length) {
        resolve(null);
      } else {
        resolve(result[0]);
      }
    } catch (error) {
      reject(error);
    }
  });
}
function findById ( id ) { return new Promise ( async ( resolve , reject ) => { try { if ( ! id || ! id . length ) { throw new Error ( 'Undefined parameter id!' ) ; } const ports = await this . find ( ) ; const result = ports . filter ( port => port . info . includes ( id ) ) ; if ( ! result . length ) { resolve ( null ) ; } else { resolve ( result [ 0 ] ) ; } } catch ( error ) { reject ( error ) ; } } ) ; }
Find a serialport by id.
@param  {String} id - The serial device id.
@return {Promise<Object|Error>}
Find a serialport by id .