<commit_before>/**
 *
 *  Iterator.js
 *
 *  copyright 2013, <NAME>
 *
 */

var classUtils = require('kld-class-utils');

/**
 *  isIterator
 *
 *  @param {Object} item
 *  @returns {Boolean}
 */
Iterator.isIterator = function(item) {
    return classUtils.conformsToInterface(item, ["hasNext", "next", "reset"]);
};

/**
 *  Iterator
 *
 *  @param {Object} items...
 *  @returns {Iterator}
 */
function Iterator() {
    var items = Array.prototype.slice.call(arguments, 0);

    this.items = (items.length == 1 && Array.isArray(items[0])) ? items[0] : items;
    this.reset();
}

/**
 *  fork
 *
 *  @returns {Iterator}
 */
Iterator.prototype.fork = function() {
    var fork = new this.constructor();

    fork.index = this.index;
    fork.items = [];

    for (var i = 0; i < this.items.length; i++) {
        var item = this.items[i];

        if (Iterator.isIterator(item)) {
            fork.items.push(item.fork());
        }
        else {
            fork.items.push(item);
        }
    }

    return fork;
};
<commit_msg>Some iterators don't have "items"<commit_after>/**
 *
 *  Iterator.js
 *
 *  copyright 2013, <NAME>
 *
 */

var classUtils = require('kld-class-utils');

/**
 *  isIterator
 *
 *  @param {Object} item
 *  @returns {Boolean}
 */
Iterator.isIterator = function(item) {
    return classUtils.conformsToInterface(item, ["hasNext", "next", "reset"]);
};

/**
 *  Iterator
 *
 *  @param {Object} items...
 *  @returns {Iterator}
 */
function Iterator() {
    var items = Array.prototype.slice.call(arguments, 0);

    this.items = (items.length == 1 && Array.isArray(items[0])) ? items[0] : items;
    this.reset();
}

/**
 *  fork
 *
 *  @returns {Iterator}
 */
Iterator.prototype.fork = function() {
    var fork = new this.constructor();

    fork.index = this.index;

    if ("items" in this) {
        fork.items = [];

        for (var i = 0; i < this.items.length; i++) {
            var item = this.items[i];

            if (Iterator.isIterator(item)) {
                fork.items.push(item.fork());
            }
            else {
                fork.items.push(item);
            }
        }
    }

    return fork;
};

{'fraction_non_alphanumeric': 0.1784059314179796, 'fraction_numerical': 0.008341056533827619, 'mean_word_length': 2.2613293051359515, 'pattern_counts': {'":': 0, '<': 7, '<?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': '1823288', 'n_tokens_mistral': 746, 'n_tokens_neox': 711, 'n_words': 146}