{"size": 686, "ext": "js", "max_stars_repo_path": "src/example/events.js", "max_stars_repo_name": "huachaoliu/ts-demo", "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "src/example/events.js", "max_issues_repo_name": "huachaoliu/ts-demo", "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "src/example/events.js", "max_forks_repo_name": "huachaoliu/ts-demo", "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null}
{"max_stars_count": null, "max_issues_count": null, "max_forks_count": null, "avg_line_length": 25.4074074074, "max_line_length": 66, "alphanum_fraction": 0.6268221574}
var toString = Object.prototype.toString;

function isFunc(source) {
    return toString.call(source) === '[object Function]';
}

function isObjecet(arg) {
    return typeof arg === 'object' && arg !== null;  
}

function addListener(type, listener) {
    if (!isFunc)
        throw TypeError("listener must be a function");

    if (!this._events)
        this._events = {};

    if (this._events.newListener) {
        this.emit('newListener', type, isFunc(listener.listener) ?
            listener.listener : listener);
    }

    if(!this._events[type]) 
        this._events[type] = listener;
    else if (isObjecet(this._events[type]))
        this._events[type].push(listener);
}