<commit_before>/**
* Predicate for Array.prototype.get*Where
* @callback chGetWherePredicate
* @param {typeOfArrayElement} element
* @return {bool}
*/

/**
 * Helps to find a specific amount of indexes by predicate
 * @param {int} amountNr Number of elements needed
 * @param {chGetWherePredicate} predicate A function that matches the syntax bool function(sourceArrayItem)
 * @returns {chGetIndexesWhere.Result}
 */
Array.prototype.chGetIndexesWhere = function chGetIndexesWhere(amountNr, predicate) {
    var sourceArray = this;
    var resultIndexes = [];
    var remained = amountNr;

    for (var i = 0; i < sourceArray.length || remained < 1; i++) {
        if (predicate(sourceArray[i])) {
            resultIndexes.push(i);
            remained--;
        }
    }

    var result = new Array.prototype.chGetIndexesWhere.Result();
    result.indexes = resultIndexes;
    result.remained = remained;

    return result;
}

/**
* Return obejct model for getIndexesWhere
* @arg {array} indexes The found indexes
* @arg {int} remained The remaining element counter where we could not found a match
*/
Array.prototype.chGetIndexesWhere.Result = function () {
    this.indexes = [];
    this.remained = 0;
}

/**
 * Helps to find a specific amount of items by predicate
 * @param {int} amountNr Number of elements needed
 * @param {chGetWherePredicate} predicate A function that matches the syntax bool function(sourceArrayItem)
 * @returns {chGetIndexesWhere.Result}
 */
Array.prototype.chGetItemsWhere = function chGetItemsWhere(amountNr, predicate) {
    var sourceArray = this;
    var resultItems = [];
    var remained = amountNr;

    for (var i = 0; i < sourceArray.length || remained < 1; i++) {
        if (predicate(sourceArray[i])) {
            resultItems.push(sourceArray[i]);
            remained--;
        }
    }

    var result = new Array.prototype.chGetItemsWhere.Result();
    result.items = resultItems;
    result.remained = remained;

    return result;
}

/**
* Return obejct model for getItemsWhere
* @arg {array} indexes The found indexes
* @arg {int} remained The remaining element counter where we could not found a match
*/
Array.prototype.chGetItemsWhere.Result = function () {
    this.items = [];
    this.remained = 0;
}<commit_msg>CH_Array found property added From now on lookup functions counts matched items by predicate<commit_after>/**
* Predicate for Array.prototype.get*Where
* @callback chGetWherePredicate
* @param {typeOfArrayElement} element
* @return {bool}
*/

/**
 * Helps to find a specific amount of indexes by predicate
 * @param {int} amountNr Number of elements needed
 * @param {chGetWherePredicate} predicate A function that matches the syntax bool function(sourceArrayItem)
 * @returns {chGetIndexesWhere.Result}
 */
Array.prototype.chGetIndexesWhere = function chGetIndexesWhere(amountNr, predicate) {
    var sourceArray = this;

    var result = new Array.prototype.chGetIndexesWhere.Result();
    result.remained = amountNr;

    for (var i = 0; i < sourceArray.length || result.remained < 1; i++) {
        if (predicate(sourceArray[i])) {
            result.indexes.push(i);
            result.found++;
            result.remained--;
        }
    }
    
    return result;
}

/**
* Return obejct model for getIndexesWhere
* @arg {array} indexes The found indexes
* @arg {int} remained The remaining element counter where we could not found a match
* @arg {int} found Number of matched items
*/
Array.prototype.chGetIndexesWhere.Result = function () {
    this.indexes = [];
    this.remained = 0;
    this.found = 0;
}

/**
 * Helps to find a specific amount of items by predicate
 * @param {int} amountNr Number of elements needed
 * @param {chGetWherePredicate} predicate A function that matches the syntax bool function(sourceArrayItem)
 * @returns {chGetIndexesWhere.Result}
 */
Array.prototype.chGetItemsWhere = function chGetItemsWhere(amountNr, predicate) {
    var sourceArray = this;

    var result = new Array.prototype.chGetItemsWhere.Result();
    result.remained = amountNr;

    for (var i = 0; i < sourceArray.length || result.remained < 1; i++) {
        if (predicate(sourceArray[i])) {
            result.items.push(sourceArray[i]);
            result.found++;
            result.remained--;
        }
    }

    return result;
}

/**
* Return obejct model for getItemsWhere
* @arg {array} indexes The found indexes
* @arg {int} remained The remaining element counter where we could not found a match
* @arg {int} found Number of matched items
*/
Array.prototype.chGetItemsWhere.Result = function () {
    this.items = [];
    this.remained = 0;
    this.found = 0;
}
{'fraction_non_alphanumeric': 0.10702772404900064, 'fraction_numerical': 0.0030088115194498175, 'mean_word_length': 3.398865784499055, 'pattern_counts': {'":': 0, '<': 11, '<?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': '732147', 'n_tokens_mistral': 1381, 'n_tokens_neox': 1333, 'n_words': 421}