<commit_before>import throat from 'throat';
import tryFn from './tryFn';
import PromiseBreak from './promiseBreak';

export default function everyLimit(collection, limit, predicate) {
    return Promise.all(collection.map(throat(limit, (item, index, collection) => {
        return tryFn(predicate, item, index, collection)
            .then((result) => {
                if (result === false) {
                    return Promise.reject(new PromiseBreak(false));
                }
                return result;
            });
    })))
        .then(() => true)
        .catch((error) => {
            if (error instanceof PromiseBreak) {<commit_msg>Add limit of 0 check to everyLimit<commit_after>import throat from 'throat';
import tryFn from './tryFn';
import PromiseBreak from './promiseBreak';

export default function everyLimit(collection, limit, predicate) {
    if (! limit > 0) {
        return Promise.reject(new Error('Limit must be a number greater than 0.'));
    }
    
    return Promise.all(collection.map(throat(limit, (item, index, collection) => {
        return tryFn(predicate, item, index, collection)
            .then((result) => {
                if (result === false) {
                    return Promise.reject(new PromiseBreak(false));
                }
                return result;
            });
    })))
        .then(() => true)
        .catch((error) => {
            if (error instanceof PromiseBreak) {
{'fraction_non_alphanumeric': 0.12681912681912683, 'fraction_numerical': 0.002079002079002079, 'mean_word_length': 2.1736263736263735, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 12, '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': '2049801', 'n_tokens_mistral': 383, 'n_tokens_neox': 365, 'n_words': 107}