<commit_before>/*#ifndef(UMD)*/
(function () { /* Begin of privacy scope */
    "use strict";
/*#endif*/

    var
        gpfI = gpf.interfaces,
        _escapes = {

            javascript: {
                "\\": "\\\\",
                "\"": "\\\"",
                "\n": "\\n",
                "\r": "\\r",
                "\t": "\\t"
            },

            xml: {
                "&": "&amp;",
                "<": "&lt;",
                ">": "&gt;"
            },

            html: {
                "&": "&amp;",
                "<": "&lt;",
                ">": "&gt;",
                "é": "&eacute;",
                "è": "&egrave;",
                "ê": "&ecirc;",
                "á": "&aacute;",
                "à": "&agrave;"
            }

        },

        /**
         * Implements ITextStream on top of a stream
         *
         * @class StringStream
         * @extend gpf.events.Target
         * @implements gpf.interfaces.ITextStream
         * @private
         */
        StringStream = gpf.define("StringStream", gpf.events.Target, {

            "[Class]": [gpf.$InterfaceImplement(gpf.interfaces.ITextStream)],

            _buffer: [],
            _pos: 0,

            constructor: function(string){
                if (undefined !== string && string.length) {
                    this._buffer = [string];
                } else {
                    this._buffer = [];
                }
                this._pos = 0;
            },

            //region gpf.interfaces.ITextStream

            /**
             * @implements gpf.interfaces.ITextStream:read
             */
            read: function(count, eventsHandler) {
                // FIFO
                var
                    firstBuffer,
                    length,
                    result;
                if (0 === this._buffer.length) {
                    gpf.events.fire(gpfI.IReadableStream.EVENT_END_OF_STREAM,
                        eventsHandler);
                } else if (undefined === count) {
                    gpf.events.fire(gpfI.IReadableStream.EVENT_DATA, {
                            buffer: this.consolidateString()
                        }, eventsHandler);
                } else {
                    firstBuffer = this._buffer[0];
                    length = firstBuffer.length;
                    if (count > length - this._pos) {
                        count = length - this._pos;
                    }
                    result = firstBuffer.substr(this._pos, count);
                    this._pos += count;
                    if (this._pos === length) {
                        this._buffer.shift();
                        this._pos = 0;
                    }
                    gpf.events.fire(gpfI.IReadableStream.EVENT_DATA, {
                        buffer: this.consolidateString()
                    }, result);
                }
            },

            /**
             * @implements gpf.interfaces.ITextStream:write
             */
            write: function (buffer, eventsHandler) {
                if (buffer && buffer.length) {
                    this._buffer.push(buffer);
                }
                gpf.events.fire(gpfI.IReadableStream.EVENT_READY,
                    eventsHandler);
            },

            //endregion

            /**
             * Consolidate the result string
             */
            consolidateString: function() {
                if (this._pos !== 0) {
                    this._buffer.unshift(
                        this._buffer.shift().substr(this._pos));
                }
                return this._buffer.join("");
            }

        });

    gpf.extend(gpf, {

        "[capitalize]": [gpf.$ClassExtension(String)],
        // Declared in base.js

        "[replaceEx]": [gpf.$ClassExtension(String)],

        /**
         * Substitutes all occurrences of the keys found in the replacements
         * object with their values
         *
         * @param {String} that
         * @param {Object} replacements map of strings to search and replace
         * @return {String}
         */
        replaceEx: function (that, replacements) {
            var
                result = that,
                key;<commit_msg>Documentation<commit_after>/*#ifndef(UMD)*/
(function () { /* Begin of privacy scope */
    "use strict";
/*#endif*/

    var
        gpfI = gpf.interfaces,
        _escapes = {

            javascript: {
                "\\": "\\\\",
                "\"": "\\\"",
                "\n": "\\n",
                "\r": "\\r",
                "\t": "\\t"
            },

            xml: {
                "&": "&amp;",
                "<": "&lt;",
                ">": "&gt;"
            },

            html: {
                "&": "&amp;",
                "<": "&lt;",
                ">": "&gt;",
                "é": "&eacute;",
                "è": "&egrave;",
                "ê": "&ecirc;",
                "á": "&aacute;",
                "à": "&agrave;"
            }

        },

        /**
         * Implements ITextStream on top of a stream
         *
         * @class StringStream
         * @extend gpf.events.Target
         * @implements gpf.interfaces.ITextStream
         * @private
         */
        StringStream = gpf.define("StringStream", gpf.events.Target, {

            "[Class]": [gpf.$InterfaceImplement(gpf.interfaces.ITextStream)],

            _buffer: [],
            _pos: 0,

            constructor: function(string){
                if (undefined !== string && string.length) {
                    this._buffer = [string];
                } else {
                    this._buffer = [];
                }
                this._pos = 0;
            },

            //region gpf.interfaces.ITextStream

            /**
             * @implements gpf.interfaces.ITextStream:read
             */
            read: function(count, eventsHandler) {
                // FIFO
                var
                    firstBuffer,
                    length,
                    result;
                if (0 === this._buffer.length) {
                    gpf.events.fire(gpfI.IReadableStream.EVENT_END_OF_STREAM,
                        eventsHandler);
                } else if (undefined === count) {
                    gpf.events.fire(gpfI.IReadableStream.EVENT_DATA, {
                            buffer: this.consolidateString()
                        }, eventsHandler);
                } else {
                    firstBuffer = this._buffer[0];
                    length = firstBuffer.length;
                    if (count > length - this._pos) {
                        count = length - this._pos;
                    }
                    result = firstBuffer.substr(this._pos, count);
                    this._pos += count;
                    if (this._pos === length) {
                        this._buffer.shift();
                        this._pos = 0;
                    }
                    gpf.events.fire(gpfI.IReadableStream.EVENT_DATA, {
                        buffer: this.consolidateString()
                    }, result);
                }
            },

            /**
             * @implements gpf.interfaces.ITextStream:write
             */
            write: function (buffer, eventsHandler) {
                if (buffer && buffer.length) {
                    this._buffer.push(buffer);
                }
                gpf.events.fire(gpfI.IReadableStream.EVENT_READY,
                    eventsHandler);
            },

            //endregion

            /**
             * Consolidate the result string
             * @return {String}
             */
            consolidateString: function() {
                if (this._pos !== 0) {
                    this._buffer.unshift(
                        this._buffer.shift().substr(this._pos));
                }
                return this._buffer.join("");
            }

        });

    gpf.extend(gpf, {

        "[capitalize]": [gpf.$ClassExtension(String)],
        // Declared in base.js

        "[replaceEx]": [gpf.$ClassExtension(String)],

        /**
         * Substitutes all occurrences of the keys found in the replacements
         * object with their values
         *
         * @param {String} that
         * @param {Object} replacements map of strings to search and replace
         * @return {String}
         */
        replaceEx: function (that, replacements) {
            var
                result = that,
                key;
{'fraction_non_alphanumeric': 0.12588069516204792, 'fraction_numerical': 0.0014091122592766556, 'mean_word_length': 0.9701596113809854, 'pattern_counts': {'":': 38, '<': 7, '<?xml version=': 0, '>': 9, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 2}, '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': '1481587', 'n_tokens_mistral': 2298, 'n_tokens_neox': 2088, 'n_words': 391}