<commit_before>define(['./stream'], function (Stream) {
    'use strict';

    /**
     * @param {Stream} stream
     * @param {Number} [wait]
     * @return {Stream}
     */
    return function timeout(stream, wait) {
        var called = 0;
        return new Stream(function(sinkValue, sinkError, sinkComplete) {
            stream.on(function(value) {
                called++;
                setTimeout(function() {
                    sinkValue(value);
                    if (!--called) {
                        sinkComplete();
                    }
                }, wait);
            }, sinkError);
        });
    };
});<commit_msg>update timeout stream to work better with push stream<commit_after>define(['./stream'], function (Stream) {
    'use strict';

    /**
     * @param {Stream} stream
     * @param {Number} [wait]
     * @return {Stream}
     */
    return function timeout(stream, wait) {
        var called = 0, completeInterval;
        return new Stream(function(sinkValue, sinkError, sinkComplete) {
            stream.on(function(value) {
                called++;
                setTimeout(function() {
                    sinkValue(value);
                    --called;
                }, wait);
            }, sinkError, function() {
                if (!called) {
                    return sinkComplete();
                }

                // Wait for complete
                completeInterval = setInterval(function() {
                    if (!called) {
                        sinkComplete();
                        clearInterval(completeInterval);
                    }
                }, wait);
            });
        });
    };
});
{'fraction_non_alphanumeric': 0.1232876712328767, 'fraction_numerical': 0.0011911852293031567, 'mean_word_length': 1.2702702702702702, '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': '1319444', 'n_tokens_mistral': 413, 'n_tokens_neox': 391, 'n_words': 90}