How to use the events.EventEmitter.apply function in events

To help you get started, we’ve selected a few events examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github DigixGlobal / truffle-lightwallet-provider / node_modules / web3-provider-engine / subproviders / filters.js View on Github external
function LogFilter(opts) {
  // console.log('LogFilter - new')
  const self = this
  EventEmitter.apply(self)
  self.type = 'log'
  self.fromBlock = opts.fromBlock || 'latest'
  self.toBlock = opts.toBlock || 'latest'
  self.address = opts.address ? normalizeHex(opts.address) : opts.address
  self.topics = opts.topics || []
  self.updates = []
  self.allResults = []
}
github node-opcua / node-opcua / packages / node-opcua-server / src / server_session.js View on Github external
function ServerSession(parent, sessionTimeout) {

    const session = this;

    session.parent = parent; // SessionEngine

    EventEmitter.apply(session, arguments);

    ServerSession.registry.register(session);

    assert(_.isFinite(sessionTimeout));
    assert(sessionTimeout >= 0, " sessionTimeout");
    session.sessionTimeout = sessionTimeout;

    const authenticationTokenBuf = crypto.randomBytes(16);
    session.authenticationToken = new NodeId(NodeIdType.BYTESTRING, authenticationTokenBuf);

    // the sessionId
    const ownNamespaceIndex = 1; // addressSpace.getOwnNamespace().index;
    session.nodeId = new NodeId(NodeIdType.GUID, ec.randomGuid(), ownNamespaceIndex);

    assert(session.authenticationToken instanceof NodeId);
    assert(session.nodeId instanceof NodeId);
github node-opcua / node-opcua / packages / node-opcua-server / src / server_engine.js View on Github external
function ServerEngine(options) {

    options = options || {};
    options.buildInfo = options.buildInfo || {};

    EventEmitter.apply(this, arguments);
    const engine = this;
    ServerEngine.registry.register(engine);

    engine._sessions = {};
    engine._closedSessions = {};
    engine._orphanPublishEngine = null; // will be constructed on demand

    engine.isAuditing = _.isBoolean(options.isAuditing) ? options.isAuditing : false;

    options.buildInfo.buildDate = options.buildInfo.buildDate || new Date();
    // ---------------------------------------------------- ServerStatus
    engine.serverStatus = new ServerStatus({
        startTime: new Date(),
        currentTime: new Date(),
        state: ServerState.NoConfiguration,
        buildInfo: options.buildInfo,
github minznerjosh / vast-player / lib / VideoTracker.js View on Github external
function VideoTracker(duration) {
    EventEmitter.apply(this, arguments); // call super()

    this.duration = duration;
    this.seconds = Array.apply([], new Array(duration)).map(function() { return false; });

    this.fired = [
        EVENTS.AdVideoStart,
        EVENTS.AdVideoFirstQuartile,
        EVENTS.AdVideoMidpoint,
        EVENTS.AdVideoThirdQuartile,
        EVENTS.AdVideoComplete
    ].reduce(function(fired, event) {
        fired[event] = false;
        return fired;
    }, {});
}
inherits(VideoTracker, EventEmitter);
github node-opcua / node-opcua / packages / node-opcua-server / src / monitored_item.js View on Github external
function MonitoredItem(options) {

    assert(options.hasOwnProperty("monitoredItemId"));
    assert(!options.monitoringMode, "use setMonitoring mode explicitly to activate the monitored item");

    EventEmitter.apply(this, arguments);
    options.itemToMonitor = options.itemToMonitor || defaultItemToMonitor;

    const self = this;
    self._samplingId = null;

    self._set_parameters(options);

    self.monitoredItemId = options.monitoredItemId; //( known as serverHandle)

    self.queue = [];
    self.overflow = false;

    self.oldDataValue = new DataValue({statusCode: StatusCodes.BadDataUnavailable}); // unset initially

    // user has to call setMonitoringMode
    self.monitoringMode = MonitoringMode.Invalid;
github mokkabonna / inquirer-autocomplete-prompt / test / helpers / readline.js View on Github external
var ReadlineStub = function() {
  this.line = '';
  this.input = new EventEmitter();
  EventEmitter.apply(this, arguments);
};
github node-opcua / node-opcua / packages / node-opcua-server / src / server_subscription.js View on Github external
function Subscription(options) {

    options = options || {};

    EventEmitter.apply(this, arguments);


    const subscription = this;

    Subscription.registry.register(subscription);

    subscription.sessionId = options.sessionId|| NodeId.nullNodeId;
    assert(subscription.sessionId instanceof NodeId,"expecting a sessionId NodeId");

    subscription.publishEngine = options.publishEngine;
    _assert_valid_publish_engine(subscription.publishEngine);

    subscription.id = options.id || "";

    subscription.priority = options.priority || 0;
github ManInTheBox / nodejs.rs / node_modules / mongoose / lib / utils.js View on Github external
Events = function () {
    EventEmitter.apply(this, arguments);
  };