<commit_before>"use strict";

// Dependencies
const Typpy = require("typpy")
    , Deffy = require("deffy")
    , SubElm = require("./subelm")
    , IterateObject = require("iterate-object")
    , NodeId = require("./id")
    , mapO = require("map-o")
    ;

class NodeElm {
    /**
     * NodeElm
     * Creates a new `NodeElm` instance.
     *
     * @name NodeElm
     * @function
     * @param {Object} data The Engine instance data, plus the following fields:
     *
     *  - `icon` (String): The node icon.
     *
     * @return {NodeElm} The `NodeElm` instance.
     */
    constructor (data) {
        this.id = new NodeId(data);
        this.icon = Deffy(data.icon, "&#xf0c0");
        this.subelms = {};
        this.label = data.name;
        this.domains = [];
        this.name = data.name;
        this.pFlow = data.flow;
        this.flow = mapO(this.pFlow, v => v.enny(), true);
        this.raw = data;
    }

    /**
     * hasFlow
     * Checks if the node has flow or not.
     *
     * @name hasFlow
     * @function
     * @return {Boolean} `true` if the node has flow, `false` otherwise.
     */
    hasFlow () {
        return !!Object(this.flow).length;
    }

    /**
     * setColor
     * Sets or gets the element color.
     *
     * @name setColor
     * @function
     * @param {String} c The new color.
     * @return {String} The set or current color.
     */
    setColor (c) {
        return (this.color = [this.color, c][arguments.length]);
    }

    /**
     * position
     * Sets the element position.
     *
     * @name position
     * @function
     * @param {Number} x The x coordinate.
     * @param {Number} y The y coordinate.
     */
    position (x, y) {
        if (Typpy(x, Number) && Typpy(y, Number)) {
            return this.position({ x: x, y: y });
        }
        if (!Typpy(x, Object) || !Typpy(x.x, Number) || !Typpy(x.y, Number)) {
            return this.pos;
        }
        this.pos = x;
    }

    /**
     * addSubElement
     *
     * @name addSubElement
     * @function
     * @param {Type} type The subelement type.
     * @param {Object} elm The subelement data.
     * @return {SubElement} The subelement instance.
     */
    addSubElement (subelm) {
        subelm = new SubElm(subelm, this);
        if (this.subelms[subelm.id]) {
            console.warn("Override", subelm);
        }
        return (this.subelms[elm.id] = elm);
    }

    /**
     * getListeners
     * Gets the listners for a specific event.
     *
     * @name getListeners
     * @function
     * @param {String} event The event you want to get the listeners for.
     * @return {Array} An array of subelements (listeners).
     */
    getListeners (event) {
        var elm = new SubElm(Enny.TYPES.listener.name, {
                event: event
            }, this)
          , id = elm.id.toString(true)
          , bubbles = []
          ;

        IterateObject(this.subelms, function (cSubelm) {
            if (cSubelm.id.toString(true) === id) {
                bubbles.push(cSubelm);
            }
        });

        return bubbles;
    }

    /**
     * getOrAddSubElm
     * Returns existing subelement or creates another one.
     *
     * @name getOrAddSubElm
     * @function
     * @param {Type} type The subelement type.
     * @param {Object} _elm The subelement data.
     * @return {SubElement} The subelement instance.
     */
    getOrAddSubElm (type, _elm) {
        var elm = new SubElm(type, _elm, this);
        if (this.subelms[elm.id]) {
            return this.subelms[elm.id];
        }
        return this.addSubElement(elm);
    }
}

module.exports = NodeElm;
<commit_msg>Fixed typo<commit_after>"use strict";

// Dependencies
const Typpy = require("typpy")
    , Deffy = require("deffy")
    , SubElm = require("./subelm")
    , IterateObject = require("iterate-object")
    , NodeId = require("./id")
    , mapO = require("map-o")
    ;

class NodeElm {
    /**
     * NodeElm
     * Creates a new `NodeElm` instance.
     *
     * @name NodeElm
     * @function
     * @param {Object} data The Engine instance data, plus the following fields:
     *
     *  - `icon` (String): The node icon.
     *
     * @return {NodeElm} The `NodeElm` instance.
     */
    constructor (data) {
        this.id = new NodeId(data);
        this.icon = Deffy(data.icon, "&#xf0c0");
        this.subelms = {};
        this.label = data.name;
        this.domains = [];
        this.name = data.name;
        this.pFlow = data.flow;
        this.flow = mapO(this.pFlow, v => v.enny(), true);
        this.raw = data;
    }

    /**
     * hasFlow
     * Checks if the node has flow or not.
     *
     * @name hasFlow
     * @function
     * @return {Boolean} `true` if the node has flow, `false` otherwise.
     */
    hasFlow () {
        return !!Object(this.flow).length;
    }

    /**
     * setColor
     * Sets or gets the element color.
     *
     * @name setColor
     * @function
     * @param {String} c The new color.
     * @return {String} The set or current color.
     */
    setColor (c) {
        return (this.color = [this.color, c][arguments.length]);
    }

    /**
     * position
     * Sets the element position.
     *
     * @name position
     * @function
     * @param {Number} x The x coordinate.
     * @param {Number} y The y coordinate.
     */
    position (x, y) {
        if (Typpy(x, Number) && Typpy(y, Number)) {
            return this.position({ x: x, y: y });
        }
        if (!Typpy(x, Object) || !Typpy(x.x, Number) || !Typpy(x.y, Number)) {
            return this.pos;
        }
        this.pos = x;
    }

    /**
     * addSubElement
     *
     * @name addSubElement
     * @function
     * @param {Type} type The subelement type.
     * @param {Object} elm The subelement data.
     * @return {SubElement} The subelement instance.
     */
    addSubElement (subelm) {
        subelm = new SubElm(subelm, this);
        if (this.subelms[subelm.id]) {
            console.warn("Override", subelm);
        }
        return (this.subelms[subelm.id] = subelm);
    }

    /**
     * getListeners
     * Gets the listners for a specific event.
     *
     * @name getListeners
     * @function
     * @param {String} event The event you want to get the listeners for.
     * @return {Array} An array of subelements (listeners).
     */
    getListeners (event) {
        var elm = new SubElm(Enny.TYPES.listener.name, {
                event: event
            }, this)
          , id = elm.id.toString(true)
          , bubbles = []
          ;

        IterateObject(this.subelms, function (cSubelm) {
            if (cSubelm.id.toString(true) === id) {
                bubbles.push(cSubelm);
            }
        });

        return bubbles;
    }

    /**
     * getOrAddSubElm
     * Returns existing subelement or creates another one.
     *
     * @name getOrAddSubElm
     * @function
     * @param {Type} type The subelement type.
     * @param {Object} _elm The subelement data.
     * @return {SubElement} The subelement instance.
     */
    getOrAddSubElm (type, _elm) {
        var elm = new SubElm(type, _elm, this);
        if (this.subelms[elm.id]) {
            return this.subelms[elm.id];
        }
        return this.addSubElement(elm);
    }
}

module.exports = NodeElm;

{'fraction_non_alphanumeric': 0.13393467268006012, 'fraction_numerical': 0.0005466721333880005, 'mean_word_length': 1.7803951367781155, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 5, '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': '3913827', 'n_tokens_mistral': 2406, 'n_tokens_neox': 2369, 'n_words': 601}