lib/serial/globaldeviceloader.js
function(callback) {
    sp.list(function(err, ports) {
      if (err && !err.name) {
        err = new Error(err);
      }
      if (err && callback) { return callback(err); }

      async.forEach(subscribers, function(s, callback) {
        if (s) {
          var resPorts = s.filter(ports);

          var devices = _.map(resPorts, function(p) {
            var found = _.find(s.oldDevices, function(dev) {
              return dev.get('portName') && p.comName && dev.get('portName').toLowerCase() === p.comName.toLowerCase();
            });
            if (found) {
              return found;
            } else {
              var newDev = new s.Device(p.comName);
              newDev.set(p);
              return newDev;
            }
          }) || [];

          s.newDevices = devices;
        }

        callback(null);
      }, function(err) {
        if (err && !err.name) {
          err = new Error(err);
        }
        if (callback) { return callback(err); }
      });
    });
  }
function(callback) {
    sp.list(function(err, ports) {
      if (err && !err.name) {
        err = new Error(err);
      }
      if (err && callback) { return callback(err); }

      async.forEach(subscribers, function(s, callback) {
        if (s) {
          var resPorts = s.filter(ports);

          var devices = _.map(resPorts, function(p) {
            var found = _.find(s.oldDevices, function(dev) {
              return dev.get('portName') && p.comName && dev.get('portName').toLowerCase() === p.comName.toLowerCase();
            });
            if (found) {
              return found;
            } else {
              var newDev = new s.Device(p.comName);
              newDev.set(p);
              return newDev;
            }
          }) || [];

          s.newDevices = devices;
        }

        callback(null);
      }, function(err) {
        if (err && !err.name) {
          err = new Error(err);
        }
        if (callback) { return callback(err); }
      });
    });
  }
function ( callback ) { sp . list ( function ( err , ports ) { if ( err && ! err . name ) { err = new Error ( err ) ; } if ( err && callback ) { return callback ( err ) ; } async . forEach ( subscribers , function ( s , callback ) { if ( s ) { var resPorts = s . filter ( ports ) ; var devices = _ . map ( resPorts , function ( p ) { var found = _ . find ( s . oldDevices , function ( dev ) { return dev . get ( 'portName' ) && p . comName && dev . get ( 'portName' ) . toLowerCase ( ) === p . comName . toLowerCase ( ) ; } ) ; if ( found ) { return found ; } else { var newDev = new s . Device ( p . comName ) ; newDev . set ( p ) ; return newDev ; } } ) || [ ] ; s . newDevices = devices ; } callback ( null ) ; } , function ( err ) { if ( err && ! err . name ) { err = new Error ( err ) ; } if ( callback ) { return callback ( err ) ; } } ) ; } ) ; }
Calls the callback when finished.
@param  {Function} callback The function, that will be called when finished lookup.
`function(err){}`
Calls the callback when finished .