Calls lookup function with optional callback
and emits 'plug' for new attached devices
and 'unplug' for removed devices.
@param  {Function} callback The function, that will be called when finished triggering. [optional]
`function(err){}`
487384
function(callback) {
    globalSerialDeviceLoader.lookup(function(err) {
      if (err && !err.name) {
        err = new Error(err);
      }
      if (err && callback) { return callback(err); }

      async.forEach(subscribers, function(s, callback) {
        if (s && s.oldDevices.length !== s.newDevices.length) {
          var devs = [];
          if (s.oldDevices.length > s.newDevices.length) {
            devs = _.difference(s.oldDevices, s.newDevices);
            _.each(devs, function(d) {
              if (s.log) s.log('unplug device with id ' + device.id);
              if (d.close) {
                d.close();
              }
              s.emit('unplug', d);
            });
          } else {
            devs = _.difference(s.newDevices, s.oldDevices);
            _.each(devs, function(d) {
              if (s.log) s.log('plug device with id ' + device.id);
              s.emit('plug', d);
            });
          }

          s.oldDevices = s.newDevices;
        }

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

    });
  }
1288549
def add_device_callback(self, callback):
        """"""
        _LOGGER.debug('Added new callback %s ', callback)
        self._cb_new_device.append(callback)
767116
function first (callback) {
        if (typeof callback !== 'function') {
          throw new Error('Callback must be a function, instead got: ' + (typeof callback));
        }

        function firstCallback (result) {
          callback(result);
          unbind('start', firstCallback);
        }

        bind('start', firstCallback);
        bind('stop', unbind.bind(null, 'end', firstCallback));

        return self;
      }
53155
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); }
      });
    });
  }
894844
function(self, callback) {
  if (self.cursorState.dead && self.cursorState.killed) {
    handleCallback(callback, new MongoError('cursor is dead'));
    return true;
  }

  return false;
}
484082
function(callback, internal) {

            var self = this;

            // Destroys the plugin and then recreates the plugin
            self._destroySelectBoxIt()._create(true);

            if(!internal) {
                self.triggerEvent("refresh");
            }

            self._callbackSupport(callback);

            //Maintains chainability
            return self;

        }
316165
function(matchFunction){
      if (this.matchFunction != matchFunction)
      {
        var oldMatchFunction = this.matchFunction;
        this.matchFunction = matchFunction;

        for (var node = this.lastChild; node; node = node.previousSibling)
          node.match(matchFunction);

        this.emit_matchFunctionChanged(oldMatchFunction);
      }
    }
860070
function(callback) {
      if (this.mysql) {
        var db = this;
        this.ready = false;
        this.mysql.end(function(error) {
          callback.call(db,error);
          if (error) {
            db.emit("error",error);
          } else {
            db.emit("close");
          }
        });
      } else {
        callback.call(this);
      }
      return this;
    }
1021134
function(callback) {
            callback = callback || function() {};
            
            var that = this;
            this.post("disable", {}, function(err, response) {
                if (err) {
                    callback(err);
                }
                else {
                    callback(null, that);
                }
            });
        }
165056
function (callback) {
            debug('');

            self.repository.on('connect', function () {
              self.emit('connect');
            });

            self.repository.on('disconnect', function () {
              self.emit('disconnect');
            });

            self.repository.connect(callback);
          }
493040
function mouseup_callback(e) {
                var press_time = new Date().getTime() - mouse_down_time;
                if (press_time < duration) {
                    // cancel the timeout
                    clearTimeout(timeout);

                    // call the shortCallback if provided
                    if (typeof shortCallback === "function") {
                        shortCallback.call($(this), e);
                    } else if (typeof shortCallback === "undefined") {
                        ;
                    } else {
                        $.error('Optional callback for short press should be a function.');
                    }
                }
            }
660529
function(callback) {
    bootstrap(behaviour, (bootstrapErr, bootstrapRes) => {
      if (bootstrapErr) api.emit("error", bootstrapErr);
      if (bootstrapRes && bootstrapRes.virgin) {
        bootstrapRes.connection.on("error", (err) => api.emit("error", err));
        bootstrapRes.connection.on("close", (why) => api.emit("error", why));
        api.emit("connected");
        bootstrapRes.pubChannel.on("error", (err) => api.emit("error", err));
        bootstrapRes.subChannel.on("error", (err) => api.emit("error", err));
        bootstrapRes.pubChannel.assertExchange(behaviour.exchange, "topic");
      }
      callback(bootstrapErr, bootstrapRes);
    });
  }
839810
function(callbacks, context){
      // avoid warnings on trying to remove handler for destroyed instance
      // since it droped all handlers
      if (this.destroy === warnOnDestroy)
        return;

      var cursor = this;
      var prev;

      context = context || this;

      // search for handler and remove it
      while (prev = cursor, cursor = cursor.handler)
        if (cursor.callbacks === callbacks && cursor.context === context)
        {
          // make it non-callable
          cursor.callbacks = NULL_HANDLER;

          // remove from list
          prev.handler = cursor.handler;

          return;
        }

      // handler not found
      /** @cut */ basis.dev.warn(namespace + '.Emitter#removeHandler: no handler removed');
    }
549926
function(interval, callback) {
    if (lookupIntervalId) {
      return;
    }

    isRunning = true;

    if (!callback && _.isFunction(interval)) {
      callback = interval;
      interval = null;
    }

    interval = interval || 500;

    globalSerialDeviceLoader.trigger(function(err) {
      var triggering = false;
      lookupIntervalId = setInterval(function() {
        if (triggering) return;
        triggering = true;
        globalSerialDeviceLoader.trigger(function() {
          triggering = false;
        });
      }, interval);

      if (err && !err.name) {
        err = new Error(err);
      }
      if (callback) { callback(err); }
    });
  }
1183259
function(callback) {
      var found = false;
      this.each(function(key, value) {
        if (callback(key, value)) {
          found = [key, value];
          return false;
        }
      });
      return found;
    }
1258221
function (callback) {
    var plugins = this.internals.plugins;
    var self = this;

    return Promise.resolve(Object.keys(APIHooks))
      .each(function (hook) {
        var plugin = plugins.hook(hook);
        if (!plugin) return;

        var APIHook = APIHooks[hook].bind(self);

        return Promise.resolve(plugin)
          .map(function (plugin) {
            return plugin[hook]();
          })
          .each(function (args) {
            return APIHook.apply(self, args);
          });
      })
      .asCallback(callback);
  }
905480
function doOnce(fn) {
    var called = false;
    return function() {
      if (called) throw new Error("Callback already called.");
      called = true;
      fn.apply(root, arguments);
    };
  }