<commit_before>/**
 * @file String related streams
 * @since 0.1.9
 */
/*#ifndef(UMD)*/
"use strict";
/*global _gpfDefine*/ // Shortcut for gpf.define
/*global _gpfStreamSecureInstallProgressFlag*/ // Install the progress flag used by _gpfStreamSecureRead and Write
/*global _gpfStreamSecureRead*/ // Generate a wrapper to secure multiple calls to stream#read
/*global _gpfStreamSecureWrite*/ // Generates a wrapper to secure multiple calls to stream#write
/*exported _GpfStreamReadableString*/ // gpf.stream.ReadableString
/*exported _GpfStreamWritableString*/ // gpf.stream.WritableString
/*#endif*/

var
    _GpfStreamReadableString = _gpfDefine(/** @lends gpf.node.ReadableString */ {
        $class: "gpf.stream.ReadableString",

        /**
         * Wraps a string inside a readable stream
         *
         * @constructor gpf.stream.ReadableString
         * @implements {gpf.interfaces.IReadableStream}
         * @param {String} buffer String buffer
         * @since 0.1.9
         */
        constructor: function (buffer) {
            this._buffer = buffer;
        },

        //region gpf.interfaces.IReadableStream

        /**
         * @gpf:sameas gpf.interfaces.IReadableStream#read
         * @since 0.1.9
         */
        read: _gpfStreamSecureRead(function (output) {
            return output.write(this._buffer); //eslint-disable-line no-invalid-this
        }),

        //endregion

        /**
         * Buffer
         * @since 0.1.9
         */
        _buffer: ""

    }),

    /**
     * @since 0.1.9
     */
    _GpfStreamWritableString = _gpfDefine(/** @lends gpf.node.WritableString */ {
        $class: "gpf.stream.WritableString",

        /**
         * Creates a writable stream that can be converted to string
         *
         * @constructor gpf.stream.WritableString
         * @implements {gpf.interfaces.IWritableStream}
         * @since 0.1.9
         */
        constructor: function () {
            this._buffer = [];
        },

        //region gpf.interfaces.IReadableStream

        /**
         * @gpf:sameas gpf.interfaces.IWritableStream#write
         * @since 0.1.9
         */
        write: _gpfStreamSecureWrite(function (buffer) {
            this._buffer.push(buffer.toString()); //eslint-disable-line no-invalid-this
            return Promise.resolve();
        }),

        //endregion

        toString: function () {
            return this._buffer.join("");
        },

        /**
         * Buffer
         *
         * @type {String[]}
         * @since 0.1.9
         */
        _buffer: []

    });

_gpfStreamSecureInstallProgressFlag(_GpfStreamReadableString);
_gpfStreamSecureInstallProgressFlag(_GpfStreamWritableString);
<commit_msg>Documentation<commit_after>/**
 * @file String related streams
 * @since 0.1.9
 */
/*#ifndef(UMD)*/
"use strict";
/*global _gpfDefine*/ // Shortcut for gpf.define
/*global _gpfStreamSecureInstallProgressFlag*/ // Install the progress flag used by _gpfStreamSecureRead and Write
/*global _gpfStreamSecureRead*/ // Generate a wrapper to secure multiple calls to stream#read
/*global _gpfStreamSecureWrite*/ // Generates a wrapper to secure multiple calls to stream#write
/*exported _GpfStreamReadableString*/ // gpf.stream.ReadableString
/*exported _GpfStreamWritableString*/ // gpf.stream.WritableString
/*#endif*/

var
    _GpfStreamReadableString = _gpfDefine(/** @lends gpf.stream.ReadableString */ {
        $class: "gpf.stream.ReadableString",

        /**
         * Wraps a string inside a readable stream
         *
         * @constructor gpf.stream.ReadableString
         * @implements {gpf.interfaces.IReadableStream}
         * @param {String} buffer String buffer
         * @since 0.1.9
         */
        constructor: function (buffer) {
            this._buffer = buffer;
        },

        //region gpf.interfaces.IReadableStream

        /**
         * @gpf:sameas gpf.interfaces.IReadableStream#read
         * @since 0.1.9
         */
        read: _gpfStreamSecureRead(function (output) {
            return output.write(this._buffer); //eslint-disable-line no-invalid-this
        }),

        //endregion

        /**
         * Buffer
         * @since 0.1.9
         */
        _buffer: ""

    }),

    /**
     * @since 0.1.9
     */
    _GpfStreamWritableString = _gpfDefine(/** @lends gpf.stream.WritableString */ {
        $class: "gpf.stream.WritableString",

        /**
         * Creates a writable stream that can be converted to string
         *
         * @constructor gpf.stream.WritableString
         * @implements {gpf.interfaces.IWritableStream}
         * @since 0.1.9
         */
        constructor: function () {
            this._buffer = [];
        },

        //region gpf.interfaces.IReadableStream

        /**
         * @gpf:sameas gpf.interfaces.IWritableStream#write
         * @since 0.1.9
         */
        write: _gpfStreamSecureWrite(function (buffer) {
            this._buffer.push(buffer.toString()); //eslint-disable-line no-invalid-this
            return Promise.resolve();
        }),

        //endregion

        toString: function () {
            return this._buffer.join("");
        },

        /**
         * Buffer
         *
         * @type {String[]}
         * @since 0.1.9
         */
        _buffer: []

    });

_gpfStreamSecureInstallProgressFlag(_GpfStreamReadableString);
_gpfStreamSecureInstallProgressFlag(_GpfStreamWritableString);

{'fraction_non_alphanumeric': 0.12041116005873716, 'fraction_numerical': 0.00881057268722467, 'mean_word_length': 2.005515719801434, 'pattern_counts': {'":': 0, '<': 3, '<?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': '4852599', 'n_tokens_mistral': 1638, 'n_tokens_neox': 1591, 'n_words': 314}