<commit_before>/**
 * Created by Awesome on 3/13/2016.
 */

// use strict
'use strict';

// require dependencies
var helper = require ('helper');

// require local dependencies
var config = require ('app/config');

/**
 * build socket helper class
 */
class socket extends helper {
    /**
     * construct socket helper class
     */
    constructor () {
        // run super
        super ();

        // bind methods
        this.room  = this.room.bind (this);
        this.user  = this.user.bind (this);
        this.emit  = this.emit.bind (this);
        this.alert = this.alert.bind (this);
    }

    /**
     * emits to room
     *
     * @param  {String} name
     * @param  {String} type
     * @param  {*}      data
     */
    room (name, type, data) {
        // emit to socket
        this.eden.emit ('socket:room', {
            'room' : name,
            'type' : type,
            'data' : data
        }, true);
    }

    /**
     * emits to user
     *
     * @param  {user}   User
     * @param  {String} type
     * @param  {*}      data
     */
    user (User, type, data) {
        // emit to socket
        this.eden.emit ('socket:user', {
            'to'   : (User ? User.get ('_id').toString () : true),
            'type' : type,
            'data' : data
        }, true);
    }

    /**
     * emit information
     *
     * @param type
     * @param data
     * @param User
     */
    emit (type, data) {
        // emit to socket
        this.eden.emit ('socket:emit', {
            'type' : type,
            'data' : data
        }, true);
    }

    /**
     * create socketio alert
     *
     * @param  {User}   User
     * @param  {String} message
     * @param  {String} type
     */
    alert (User, message, type, options) {
        // create alert object
        var alert = {
            'type'    : type,
            'message' : message
        };

        // set variables
        if (options) {
            alert.options = options;
        }

        // emit to redis
        this.user (User, 'alert', alert);
    }<commit_msg>add option to emit to all to socket<commit_after>/**
 * Created by Awesome on 3/13/2016.
 */

// use strict
'use strict';

// require dependencies
var helper = require ('helper');

// require local dependencies
var config = require ('app/config');

/**
 * build socket helper class
 */
class socket extends helper {
    /**
     * construct socket helper class
     */
    constructor () {
        // run super
        super ();

        // bind methods
        this.room  = this.room.bind (this);
        this.user  = this.user.bind (this);
        this.emit  = this.emit.bind (this);
        this.alert = this.alert.bind (this);
    }

    /**
     * emits to room
     *
     * @param  {String}  name
     * @param  {String}  type
     * @param  {*}       data
     * @param  {Boolean} all
     */
    room (name, type, data, all) {
        // emit to socket
        this.eden.emit ('socket:room', {
            'room' : name,
            'type' : type,
            'data' : data
        }, all);
    }

    /**
     * emits to user
     *
     * @param  {user}    User
     * @param  {String}  type
     * @param  {*}       data
     * @param  {Boolean} all
     */
    user (User, type, data, all) {
        // emit to socket
        this.eden.emit ('socket:user', {
            'to'   : (User ? User.get ('_id').toString () : true),
            'type' : type,
            'data' : data
        }, all);
    }

    /**
     * emit information
     *
     * @param  {String}  type
     * @param  {*}       data
     * @param  {user}    User
     * @param  {Boolean} all
     */
    emit (type, data, all) {
        // emit to socket
        this.eden.emit ('socket:emit', {
            'type' : type,
            'data' : data
        }, all);
    }

    /**
     * create socketio alert
     *
     * @param  {User}   User
     * @param  {String} message
     * @param  {String} type
     */
    alert (User, message, type, options) {
        // create alert object
        var alert = {
            'type'    : type,
            'message' : message
        };

        // set variables
        if (options) {
            alert.options = options;
        }

        // emit to redis
        this.user (User, 'alert', alert);
    }
{'fraction_non_alphanumeric': 0.14292343387471, 'fraction_numerical': 0.0032482598607888632, 'mean_word_length': 1.3544511196067723, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, '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': '231790', 'n_tokens_mistral': 1331, 'n_tokens_neox': 1309, 'n_words': 361}