Create an event
@param  {Object}   data A data object
@return {Function}      A promise
434929
function (data) {
    var path;
    if (data) {
      path = this.constructPath(constants.EVENTS);
      return this.Places.POST(path, data);
    } else {
      return this.rejectRequest('Bad Request: A data object is required.');
    }
  }
1286727
function request (event, data) {
    return new Promise(function (resolve, reject) {
      // put the data in an envelope with id
      var id = getId();
      var envelope = {
        event: event,
        id: id,
        data: data
      };

      // add the request to the list with requests in progress
      queue[id] = {
        resolve: resolve,
        reject: reject,
        timeout: setTimeout(function () {
          delete queue[id];
          reject(new Error('Timeout'));
        }, TIMEOUT)
      };

      debug('request', envelope);
      socket.send(JSON.stringify(envelope));
    }).catch(function (err) {console.log('ERROR', err)});
  }
596276
function (data) {
        var name, value;

        data = data || {};

        for (name in data) {
          value = data[name];

          if (value instanceof Binding) {
            data[name] = value.create(this, name);
          }
        }

        this.data = data;
      }
528557
function buildEvent (id, title, display, hidden = {}) {
  const eventObj = {
    id,
    title,
    display,
    hidden,
    status: 'active',
    timestamp: new Date(Date.now()).toISOString()
  };
  return eventObj;
}
540951
function(data) {
      var that = this;
      var model = new Tabletop.Model( { data: data, 
                                        parseNumbers: this.parseNumbers,
                                        postProcess: this.postProcess,
                                        tabletop: this,
                                        prettyColumnNames: this.prettyColumnNames,
                                        onReady: function() {
                                          that.sheetReady(this);
                                        } } );
    }
522918
def new_event(self, event_data: str) -> None:
        """"""
        event = self.parse_event_xml(event_data)

        if EVENT_OPERATION in event:
            self.manage_event(event)
1297549
function setEventData(events) { // events are already normalized at this point
		eventsByID = {};
		var i, len=events.length, event;
		for (i=0; i<len; i++) {
			event = events[i];
			if (eventsByID[event._id]) {
				eventsByID[event._id].push(event);
			}else{
				eventsByID[event._id] = [event];
			}
		}
	}
469098
def __create_event(self):
        
        if not event.contains(self.field, 'set', self.__validate):
            event.listen(self.field, 'set', self.__validate, retval=True)
276559
function Promise(o){
	var self = this;
	
        // object mixin
        if(o && typeof o === 'object'){
            for(var k in Promise.prototype)
		o[k] = Promise.prototype[k];
	    o._promise = {_chain:[]};

	    return o;
        }
	
	// create new instance
        if(!(this instanceof Promise))
            return new Promise(o);

	this._promise = {_chain: []};

        // use resolver callback
        if(typeof o === 'function') {
	    task(function(){
		var res = self.resolve.bind(self),
		    rej = self.reject.bind(self);
		o(res,rej);
	    });
        }
    }
571394
function onData( data ) {
		for ( var i = 0; i < data.length; i++ ) {
			this.queue( data[ i ] );
		}
	}
1079040
function eventPromise (emitter, eventName) {
  return new Promise((resolve, reject) => {
    emitter.on(eventName, (...args) => {
      return resolve(args)
    })
  })
}
929132
function createEvent(type, options) {
  switch (type) {
    case 'dblclick':
    case 'click':
      return createMouseEvent(type, options);
    case 'keydown':
    case 'keyup':
      return createKeyboardEvent(type, options);
  }
}
207320
async function (events) {
    const oThis = this
      , promiseArray = []
    ;

    // nothing to do
    if (!events || events.length === 0) {
      oThis.updateIntercomDataFile();
      return Promise.resolve();
    }

    //TODO: last processed transaction index.
    for (var i = 0; i < events.length; i++) {
      const eventObj = events[i]
        , j = i
      ;

      // await oThis.processEventObj(eventObj);

      if (oThis.parallelProcessingAllowed()) {
        promiseArray.push(new Promise(function (onResolve, onReject) {
          setTimeout(function () {
            oThis.processEventObj(eventObj)
              .then(onResolve)
              .catch(function (error) {
                logger.error('##### inside catch block #####: ', error);
                return onResolve();
              });
          }, (j * 1000 + 100));
        }));
      } else {
        await oThis.processEventObj(eventObj)
          .catch(function (error) {
            logger.error('inside catch block: ', error);
            return Promise.resolve();
          });
      }
    }

    if (oThis.parallelProcessingAllowed()) {
      await Promise.all(promiseArray);
    }

    oThis.updateIntercomDataFile();
    return Promise.resolve();
  }
614755
function onevent(event) {
        // Event should have the following properties:
        // * `id: string`: an event identifier.
        // * `type: string`: an event type.
        // * `data: any`: an event data.
        // * `reply: boolean`: true if this event requires the reply.

        // If the client sends a plain event, dispatch it.
        if (!event.reply) {
          self.emit(event.type, event.data);
        } else {
          var latch;
          // A function to create a function.
          function reply(success) {
            // A controller function.
            return function(value) {
              // This latch prevents double reply.
              if (!latch) {
                latch = true;
                self.send("reply", {id: event.id, data: value, exception: !success});
              }
            };
          }

          // Here, the controller is passed to the event handler as 2nd argument and allows
          // to call the server's `resolved` or `rejected` callback by sending `reply` event.
          self.emit(event.type, event.data, {resolve: reply(true), reject: reply(false)});
        }
      }
137282
def put_event(self, data):
        
        try:
            event = self._factory.create(data)
            self._events.put(event)
        except Full:
            raise GerritError("Unable to add event: queue is full")
1116008
function createEvent(params, cb) {
  params.resourcePath = config.addURIParams(constants.EVENTS_BASE_PATH, params);
  params.method = 'POST';
  params.data = params.data || {};
  mbaasRequest.admin(params, cb);
}
1188806
function() {

		// Create an object which inherits its parent as the prototype and constructs a new event chain.
		var _this = this;
		var utils = _this.utils;
		var error = utils.error;
		var promise = utils.Promise();

		// Get parameters
		var p = utils.args({network: 's', options: 'o', callback: 'f'}, arguments);

		// Local vars
		var url;

		// Get all the custom options and store to be appended to the querystring
		var qs = utils.diffKey(p.options, _this.settings);

		// Merge/override options with app defaults
		var opts = p.options = utils.merge(_this.settings, p.options || {});

		// Merge/override options with app defaults
		opts.popup = utils.merge(_this.settings.popup, p.options.popup || {});

		// Network
		p.network = p.network || _this.settings.default_service;

		// Bind callback to both reject and fulfill states
		promise.proxy.then(p.callback, p.callback);

		// Trigger an event on the global listener
		function emit(s, value) {
			hello.emit(s, value);
		}

		promise.proxy.then(emit.bind(this, 'auth.login auth'), emit.bind(this, 'auth.failed auth'));

		// Is our service valid?
		if (typeof (p.network) !== 'string' || !(p.network in _this.services)) {
			// Trigger the default login.
			// Ahh we dont have one.
			return promise.reject(error('invalid_network', 'The provided network was not recognized'));
		}

		var provider = _this.services[p.network];

		// Create a global listener to capture events triggered out of scope
		var callbackId = utils.globalEvent(function(obj) {

			// The responseHandler returns a string, lets save this locally
			if (obj) {
				if (typeof (obj) == 'string') {
					obj = JSON.parse(obj);
				}
			}
			else {
				obj = error('cancelled', 'The authentication was not completed');
			}

			// Handle these response using the local
			// Trigger on the parent
			if (!obj.error) {

				// Save on the parent window the new credentials
				// This fixes an IE10 bug i think... atleast it does for me.
				utils.store(obj.network, obj);

				// Fulfill a successful login
				promise.fulfill({
					network: obj.network,
					authResponse: obj
				});
			}
			else {
				// Reject a successful login
				promise.reject(obj);
			}
		});

		var redirectUri = utils.url(opts.redirect_uri).href;

		// May be a space-delimited list of multiple, complementary types
		var responseType = provider.oauth.response_type || opts.response_type;

		// Fallback to token if the module hasn't defined a grant url
		if (/\bcode\b/.test(responseType) && !provider.oauth.grant) {
			responseType = responseType.replace(/\bcode\b/, 'token');
		}

		// Query string parameters, we may pass our own arguments to form the querystring
		p.qs = utils.merge(qs, {
			client_id: encodeURIComponent(provider.id),
			response_type: encodeURIComponent(responseType),
			redirect_uri: encodeURIComponent(redirectUri),
			state: {
				client_id: provider.id,
				network: p.network,
				display: opts.display,
				callback: callbackId,
				state: opts.state,
				redirect_uri: redirectUri
			}
		});

		// Get current session for merging scopes, and for quick auth response
		var session = utils.store(p.network);

		// Scopes (authentication permisions)
		// Ensure this is a string - IE has a problem moving Arrays between windows
		// Append the setup scope
		var SCOPE_SPLIT = /[,\s]+/;

		// Include default scope settings (cloned).
		var scope = _this.settings.scope ? [_this.settings.scope.toString()] : [];

		// Extend the providers scope list with the default
		var scopeMap = utils.merge(_this.settings.scope_map, provider.scope || {});

		// Add user defined scopes...
		if (opts.scope) {
			scope.push(opts.scope.toString());
		}

		// Append scopes from a previous session.
		// This helps keep app credentials constant,
		// Avoiding having to keep tabs on what scopes are authorized
		if (session && 'scope' in session && session.scope instanceof String) {
			scope.push(session.scope);
		}

		// Join and Split again
		scope = scope.join(',').split(SCOPE_SPLIT);

		// Format remove duplicates and empty values
		scope = utils.unique(scope).filter(filterEmpty);

		// Save the the scopes to the state with the names that they were requested with.
		p.qs.state.scope = scope.join(',');

		// Map scopes to the providers naming convention
		scope = scope.map(function(item) {
			// Does this have a mapping?
			return (item in scopeMap) ? scopeMap[item] : item;
		});

		// Stringify and Arrayify so that double mapped scopes are given the chance to be formatted
		scope = scope.join(',').split(SCOPE_SPLIT);

		// Again...
		// Format remove duplicates and empty values
		scope = utils.unique(scope).filter(filterEmpty);

		// Join with the expected scope delimiter into a string
		p.qs.scope = scope.join(provider.scope_delim || ',');

		// Is the user already signed in with the appropriate scopes, valid access_token?
		if (opts.force === false) {

			if (session && 'access_token' in session && session.access_token && 'expires' in session && session.expires > ((new Date()).getTime() / 1e3)) {
				// What is different about the scopes in the session vs the scopes in the new login?
				var diff = utils.diff((session.scope || '').split(SCOPE_SPLIT), (p.qs.state.scope || '').split(SCOPE_SPLIT));
				if (diff.length === 0) {

					// OK trigger the callback
					promise.fulfill({
						unchanged: true,
						network: p.network,
						authResponse: session
					});

					// Nothing has changed
					return promise;
				}
			}
		}

		// Page URL
		if (opts.display === 'page' && opts.page_uri) {
			// Add a page location, place to endup after session has authenticated
			p.qs.state.page_uri = utils.url(opts.page_uri).href;
		}

		// Bespoke
		// Override login querystrings from auth_options
		if ('login' in provider && typeof (provider.login) === 'function') {
			// Format the paramaters according to the providers formatting function
			provider.login(p);
		}

		// Add OAuth to state
		// Where the service is going to take advantage of the oauth_proxy
		if (!/\btoken\b/.test(responseType) ||
		parseInt(provider.oauth.version, 10) < 2 ||
		(opts.display === 'none' && provider.oauth.grant && session && session.refresh_token)) {

			// Add the oauth endpoints
			p.qs.state.oauth = provider.oauth;

			// Add the proxy url
			p.qs.state.oauth_proxy = opts.oauth_proxy;

		}

		// Convert state to a string
		p.qs.state = encodeURIComponent(JSON.stringify(p.qs.state));

		// URL
		if (parseInt(provider.oauth.version, 10) === 1) {

			// Turn the request to the OAuth Proxy for 3-legged auth
			url = utils.qs(opts.oauth_proxy, p.qs, encodeFunction);
		}

		// Refresh token
		else if (opts.display === 'none' && provider.oauth.grant && session && session.refresh_token) {

			// Add the refresh_token to the request
			p.qs.refresh_token = session.refresh_token;

			// Define the request path
			url = utils.qs(opts.oauth_proxy, p.qs, encodeFunction);
		}
		else {
			url = utils.qs(provider.oauth.auth, p.qs, encodeFunction);
		}

		// Broadcast this event as an auth:init
		emit('auth.init', p);

		// Execute
		// Trigger how we want self displayed
		if (opts.display === 'none') {
			// Sign-in in the background, iframe
			utils.iframe(url, redirectUri);
		}

		// Triggering popup?
		else if (opts.display === 'popup') {

			var popup = utils.popup(url, redirectUri, opts.popup);

			var timer = setInterval(function() {
				if (!popup || popup.closed) {
					clearInterval(timer);
					if (!promise.state) {

						var response = error('cancelled', 'Login has been cancelled');

						if (!popup) {
							response = error('blocked', 'Popup was blocked');
						}

						response.network = p.network;

						promise.reject(response);
					}
				}
			}, 100);
		}

		else {
			window.location = url;
		}

		return promise.proxy;

		function encodeFunction(s) {return s;}

		function filterEmpty(s) {return !!s;}
	}