<commit_before>/**
 * Module dependencies
 */

var _ = require('@sailshq/lodash');
var async = require('async');


//
// TODO
// Pull this into a separate module, since it's not specific to Sails.
//


/**
 * Mix-in an `after` function to an EventEmitter.
 *
 * If `events` have already fired, trigger fn immediately (with no args)
 * Otherwise bind a normal one-time event using `EventEmitter.prototype.once()`.
 * Useful for checking whether or not something has finished loading, etc.
 *
 * This is a lot like jQuery's `$(document).ready()`.
 *
 * @param  {EventEmitter} emitter
 */

module.exports = function mixinAfter(emitter) {


  /**
   * { emitter.warmEvents }
   *
   * Events which have occurred at least once
   * (Required to support `emitter.after()`)
   */
  emitter.warmEvents = {};


  /**
   * emitter.emit()
   *
   * Override `EventEmitter.prototype.emit`.
   * (Required to support `emitter.after()`)
   */

  var _emit = emitter.emit;
  emitter.emit = function(evName) {
    var args = Array.prototype.slice.call(arguments, 0);
    emitter.warmEvents[evName] = true;
    _emit.apply(emitter, args);
  };


  /**
   * `emitter.after()`
   *
   * Fires your handler **IF THE SPECIFIED EVENT HAS ALREADY BEEN TRIGGERED** or **WHEN IT IS TRIGGERED**.
   *
   * @param  {String|Array} events   [name of the event(s)]<commit_msg>Make emit 100% EventEmitter.emit compatible<commit_after>/**
 * Module dependencies
 */

var _ = require('@sailshq/lodash');
var async = require('async');


//
// TODO
// Pull this into a separate module, since it's not specific to Sails.
//


/**
 * Mix-in an `after` function to an EventEmitter.
 *
 * If `events` have already fired, trigger fn immediately (with no args)
 * Otherwise bind a normal one-time event using `EventEmitter.prototype.once()`.
 * Useful for checking whether or not something has finished loading, etc.
 *
 * This is a lot like jQuery's `$(document).ready()`.
 *
 * @param  {EventEmitter} emitter The Sails application instance
 */

module.exports = function mixinAfter(emitter) {


  /**
   * { emitter.warmEvents }
   *
   * Events which have occurred at least once
   * (Required to support `emitter.after()`)
   */
  emitter.warmEvents = {};


  var _emit = emitter.emit;
  /**
   * emitter.emit()
   *
   * Synchronously calls each of the listeners registered for the event named eventName, in the order they were registered, passing the supplied arguments to each.
   *
   * Override `EventEmitter.prototype.emit` to keep track of all the events that have occurred once.
   * (Required to support `emitter.after()`)
   *
   * @param {String} eventName name of the event
   * @return {boolean} Returns true if the event had listeners, false otherwise.
   * @see https://nodejs.org/api/events.html#events_emitter_emit_eventname_args
   */
  emitter.emit = function(eventName) {
    var args = Array.prototype.slice.call(arguments, 0);
    emitter.warmEvents[eventName] = true;
    return _emit.apply(emitter, args);
  };


  /**
   * `emitter.after()`
   *
   * Fires your handler **IF THE SPECIFIED EVENT HAS ALREADY BEEN TRIGGERED** or **WHEN IT IS TRIGGERED**.
   *
   * @param  {String|Array} events   [name of the event(s)]
{'fraction_non_alphanumeric': 0.12792511700468018, 'fraction_numerical': 0.0015600624024961, 'mean_word_length': 3.3149394347240917, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 1, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6240367', 'n_tokens_mistral': 1024, 'n_tokens_neox': 969, 'n_words': 319}