<commit_before>/*
 * eV / ev.js
 * copyright (c) 2014 Susisu
 */

"use strict";

function end() {
    module.exports = Object.freeze({
        "EventPhase"     : EventPhase,
        "Event"          : Event,
        "EventDispatcher": EventDispatcher,
        "EventNode"      : EventNode
    });
}


var EventPhase = Object.freeze({
    "AT_TARGET"      : 2,
    "BUBBLING_PHASE" : 3,
    "CAPTURING_PHASE": 1
});


function Event(type, bubbles, cancelable) {
    /* private properties */
    this._type             = type;
    this._bubbles          = bubbles;
    this._cancelable       = cancelable;
    this._defaultPrevented = false;

    /* internal properties */
    this._eventPhase                  = EventPhase.AT_TARGET;
    this._target                      = null;
    this._currentTarget               = null;
    this._propagationStopped          = false;
    this._immediatePropagationStopped = false;
}

Object.defineProperties(Event.prototype, {
    /* getter / setter properties */
    "type": {
        "get": function () { return this._type; }
    },

    "bubbles": {
        "get": function () { return this._bubbles; }
    },

    "cancelable": {
        "get": function () { return this._cancelable; }
    },

    "eventPhase": {
        "get": function () { return this._eventPhase; }
    },

    "target": {
        "get": function () { return this._target; }
    },

    "currentTarget": {
        "get": function () { return this._currentTarget; }
    },

    /* methods */
    "clone": {
        "value": function () {
            return new Event(this._type, this._bubbles, this._cancelable);
        }
    },

    "formatToString": {
        "value": function (className, propNames) {
            var str = "[" + className;
            for (var i = 0; i < propNames.length; i++) {
                var name  = propNames[i];
                var value = this[name];
                if (typeof value === "string") {
                    str += " " + name + "=\"" + value + "\"";
                }
                else {
                    str += " " + name + "=" + String(value);
                }
            }
            str += "]";<commit_msg>Add type checking in the methods of 'Event'<commit_after>/*
 * eV / ev.js
 * copyright (c) 2014 Susisu
 */

"use strict";

function end() {
    module.exports = Object.freeze({
        "EventPhase"     : EventPhase,
        "Event"          : Event,
        "EventDispatcher": EventDispatcher,
        "EventNode"      : EventNode
    });
}


var EventPhase = Object.freeze({
    "AT_TARGET"      : 2,
    "BUBBLING_PHASE" : 3,
    "CAPTURING_PHASE": 1
});


function Event(type, bubbles, cancelable) {
    if (typeof type !== "string") {
        throw new TypeError("'type' should be a string");
    }
    if (typeof bubbles !== "boolean") {
        bubbles = false;
    }
    if (typeof cancelable !== "boolean") {
        cancelable = false;
    }

    /* private properties */
    this._type             = type;
    this._bubbles          = bubbles;
    this._cancelable       = cancelable;
    this._defaultPrevented = false;

    /* internal properties */
    this._eventPhase                  = EventPhase.AT_TARGET;
    this._target                      = null;
    this._currentTarget               = null;
    this._propagationStopped          = false;
    this._immediatePropagationStopped = false;
}

Object.defineProperties(Event.prototype, {
    /* getter / setter properties */
    "type": {
        "get": function () { return this._type; }
    },

    "bubbles": {
        "get": function () { return this._bubbles; }
    },

    "cancelable": {
        "get": function () { return this._cancelable; }
    },

    "eventPhase": {
        "get": function () { return this._eventPhase; }
    },

    "target": {
        "get": function () { return this._target; }
    },

    "currentTarget": {
        "get": function () { return this._currentTarget; }
    },

    /* methods */
    "clone": {
        "value": function () {
            return new Event(this._type, this._bubbles, this._cancelable);
        }
    },

    "formatToString": {
        "value": function (className, propNames) {
            if (typeof className !== "string") {
                throw new TypeError("'className' should be a string");
            }
            
            var str = "[" + className;
            for (var i = 0; i < propNames.length; i++) {
                var name  = propNames[i];
                var value = this[name];
                if (typeof value === "string") {
                    str += " " + name + "=\"" + value + "\"";
                }
                else {
                    str += " " + name + "=" + String(value);
                }
            }
            str += "]";
{'fraction_non_alphanumeric': 0.14231896190874843, 'fraction_numerical': 0.0033486814566764337, 'mean_word_length': 1.6057797164667393, 'pattern_counts': {'":': 36, '<': 5, '<?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': '1390630', 'n_tokens_mistral': 1428, 'n_tokens_neox': 1359, 'n_words': 305}