<commit_before>var _ = require('underscore'),
    passError = require('passerror'),
    seq = require('seq'),
    assets = require('../assets');

// Takes assetConfigs, urls or root-relative paths or arrays of these
module.exports = function () { // ...
    var assetConfigs = _.flatten(arguments);
    return function loadAssets(assetGraph, cb) {
        assets.resolveConfig(assetConfigs, assetGraph.root, assetGraph, passError(cb, function (resolvedAssetConfigs) {
            seq(_.isArray(resolvedAssetConfigs) ? resolvedAssetConfigs : [resolvedAssetConfigs])
                .parEach(function (resolvedAssetConfig) {
                    resolvedAssetConfig.isInitial = true;
                    assets.ensureAssetConfigHasType(resolvedAssetConfig, assetGraph, this);
                })
                .parMap(function (resolvedAssetConfig) {
                    var callback = this,
                        asset = assets.create(resolvedAssetConfig);
                    if (asset.keepUnloaded) {
                        callback(null, asset);
                    } else {
                        asset.load(function (err) {
                            if (err) {
                                assetGraph.emit('error', err);
                                callback();
                            } else {
                                callback(null, asset);
                            }
                        });
                    }
                })
                .unflatten()
                .seq(function (_assets) {
                    // Make sure that parse errors and the like get propagated to cb:
                    try {
                        _assets.forEach(function (asset) {
                            if (asset) {
                                assetGraph.addAsset(asset);
                            }<commit_msg>transforms.loadAssets: Limit the concurrency to 10 when loading the assets.<commit_after>var _ = require('underscore'),
    passError = require('passerror'),
    seq = require('seq'),
    assets = require('../assets');

// Takes assetConfigs, urls or root-relative paths or arrays of these
module.exports = function () { // ...
    var assetConfigs = _.flatten(arguments);
    return function loadAssets(assetGraph, cb) {
        assets.resolveConfig(assetConfigs, assetGraph.root, assetGraph, passError(cb, function (resolvedAssetConfigs) {
            seq(_.isArray(resolvedAssetConfigs) ? resolvedAssetConfigs : [resolvedAssetConfigs])
                .parEach(function (resolvedAssetConfig) {
                    resolvedAssetConfig.isInitial = true;
                    assets.ensureAssetConfigHasType(resolvedAssetConfig, assetGraph, this);
                })
                .parMap(10, function (resolvedAssetConfig) {
                    var callback = this,
                        asset = assets.create(resolvedAssetConfig);
                    if (asset.keepUnloaded) {
                        callback(null, asset);
                    } else {
                        asset.load(function (err) {
                            if (err) {
                                assetGraph.emit('error', err);
                                callback();
                            } else {
                                callback(null, asset);
                            }
                        });
                    }
                })
                .unflatten()
                .seq(function (_assets) {
                    // Make sure that parse errors and the like get propagated to cb:
                    try {
                        _assets.forEach(function (asset) {
                            if (asset) {
                                assetGraph.addAsset(asset);
                            }
{'fraction_non_alphanumeric': 0.08960763520678686, 'fraction_numerical': 0.0010604453870625664, 'mean_word_length': 1.231224127735068, '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': '4711479', 'n_tokens_mistral': 863, 'n_tokens_neox': 807, 'n_words': 182}