<commit_before>exports.result = function(value) {
    if (value instanceof Function) {
        var args = Array.prototype.slice.call(arguments, 1);
        value    = value.apply(null, args);
    }

    return value;
};

exports.waitForAllPromises = function(promises) {
    var errors = [];

    var resolvedPromises = promises.map(function(promise) {
        return promise.catch(function(err) {
            if (err instanceof Error) {
                return Promise.reject(err);
            }

            if (!(err instanceof Array)) {
                err = [err];
            }

            Array.prototype.push.apply(errors, err);

            return Promise.resolve();
        });
    });

    return Promise.all(resolvedPromises).then(function() {
        if (errors.length) {
            return Promise.reject(errors);
        }
    });
};<commit_msg>docblock<commit_after>/**
 * @param {*} value
 *
 * @returns {*}
 */
exports.result = function(value) {
    if (value instanceof Function) {
        var args = Array.prototype.slice.call(arguments, 1);
        value    = value.apply(null, args);
    }

    return value;
};

/**
 * @param {Promise[]} promises
 *
 * @returns {Promise}
 */
exports.waitForAllPromises = function(promises) {
    var errors = [];

    var resolvedPromises = promises.map(function(promise) {
        return promise.catch(function(err) {
            if (err instanceof Error) {
                return Promise.reject(err);
            }

            if (!(err instanceof Array)) {
                err = [err];
            }

            Array.prototype.push.apply(errors, err);

            return Promise.resolve();
        });
    });

    return Promise.all(resolvedPromises).then(function() {
        if (errors.length) {
            return Promise.reject(errors);
        }
    });
};
{'fraction_non_alphanumeric': 0.13472070098576122, 'fraction_numerical': 0.001095290251916758, 'mean_word_length': 1.9420289855072463, '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': '6862930', 'n_tokens_mistral': 513, 'n_tokens_neox': 494, 'n_words': 101}