<commit_before>//
// Patch PIXI to emit "added"/"removed" events on global event dispatcher
//

import "./eventemitter3-patch";
import PIXI = require("pixi.js");

export function applyPixiPatch(interaction: any) {
    let addChild = PIXI.Container.prototype.addChild;
    let addChildAt = PIXI.Container.prototype.addChildAt;
    let removeChild = PIXI.Container.prototype.removeChild;
    let removeChildAt = PIXI.Container.prototype.removeChildAt;

    PIXI.Container.prototype.addChild = function patchedAddChild<
        T extends PIXI.DisplayObject
    >(...child: T[]) {
        for (let i = 0, len = child.length; i < len; i++) {
            addChild.call(this, child[i]);
            interaction.emit("added", { target: child[i] });
        }
        return this;
    };

    PIXI.Container.prototype.addChildAt = function patchedAddChildAt<
        T extends PIXI.DisplayObject
    >(child: T, index: number): T {
        addChildAt.call(this, child, index);
        interaction.emit("added", { target: child });
        return this;
    };

    PIXI.Container.prototype.removeChild = function(
        ...child
    ): PIXI.DisplayObject {
        for (let i = 0, len = child.length; i < len; i++) {
            removeChild.call(this, child[i]);
            interaction.emit("removed", { target: child[i] });
        }
        return this;
    };

    PIXI.Container.prototype.removeChildAt = function(
        index
    ): PIXI.DisplayObject {
        let child = removeChildAt.call(this, index);
        interaction.emit("removed", { target: child });
        return this;
    };
}
<commit_msg>showcasing a possible solution for #14<commit_after>//
// Patch PIXI to emit "added"/"removed" events on global event dispatcher
//

import "./eventemitter3-patch";
import PIXI = require("pixi.js");

export function applyPixiPatch(interaction: any) {
    let addChild = PIXI.Container.prototype.addChild;
    let addChildAt = PIXI.Container.prototype.addChildAt;
    let removeChild = PIXI.Container.prototype.removeChild;
    let removeChildren = PIXI.Container.prototype.removeChildren;
    let removeChildAt = PIXI.Container.prototype.removeChildAt;

    PIXI.Container.prototype.addChild = function patchedAddChild<
        T extends PIXI.DisplayObject
    >(...child: T[]) {
        for (let i = 0, len = child.length; i < len; i++) {
            addChild.call(this, child[i]);
            interaction.emit("added", { target: child[i] });
        }
        return this;
    };

    PIXI.Container.prototype.addChildAt = function patchedAddChildAt<
        T extends PIXI.DisplayObject
    >(child: T, index: number): T {
        addChildAt.call(this, child, index);
        interaction.emit("added", { target: child });
        return this;
    };

    PIXI.Container.prototype.removeChild = function(
        ...child
    ): PIXI.DisplayObject {
        for (let i = 0, len = child.length; i < len; i++) {
            removeChild.call(this, child[i]);
            interaction.emit("removed", { target: child[i] });
        }
        return this;
    };
  PIXI.Container.prototype.removeChildren = function (beginIndex: number = 0, endIndex?: number) {
    const end = endIndex || this.children.length;
    const range = end - beginIndex;
    const children = this.children.slice(beginIndex, range);

    for (let child of children) {
      interaction.emit("removed", { target: child });
    }

    return removeChildren.call(this, beginIndex, end);
  };
    PIXI.Container.prototype.removeChildAt = function(
        index
    ): PIXI.DisplayObject {
        let child = removeChildAt.call(this, index);
        interaction.emit("removed", { target: child });
        return this;
    };
}

{'fraction_non_alphanumeric': 0.12911939492166397, 'fraction_numerical': 0.0024311183144246355, 'mean_word_length': 2.673611111111111, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 7, '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': '5627919', 'n_tokens_mistral': 1121, 'n_tokens_neox': 1102, 'n_words': 255}