OpenVeo server API for plugins

API Docs for: 7.0.0
Show:

File: lib/emitters/AdvancedEvent.js

'use strict';

/**
 * @module emitters
 */

/**
 * Defines an AdvancedEvent to work with an AdvancedEmitter.
 *
 * It duplicates the name argument to have twice the event's name
 * as first and second arguments.
 *
 * @class AdvancedEvent
 * @constructor
 * @param {String} name The event's name
 * @param {mixed} [...args] Any number of arguments
 */
function AdvancedEvent() {

  // Transform arguments into an array
  var args = Array.prototype.slice.call(arguments);

  // Duplicate "name" argument to have twice the event's name
  // as first and second arguments
  args.unshift(arguments[0]);

  Object.defineProperties(this, {

    /**
     * The list of event's arguments.
     *
     * @property arguments
     * @type Object
     * @final
     */
    arguments: {value: args}

  });
}

module.exports = AdvancedEvent;