<commit_before>'use strict';
var _ = require('lodash');
var util = require('util');
var paramNames = require('get-parameter-names');

module.exports = function applyMaps(maps, steps) {
    if (_.isNil(maps)) {
        return convertStepsToArray(steps);
    }
    if (!_.isObject(maps)) {
        throw new Error(util.format('The passed in map must be an object or null if no mapping is required. Type : "%s". Value : "%j"', typeof maps, maps));
    }
    applySkip(maps.skip, steps); //done
    applySkipIfExists(maps.skipIfExists, steps);//done
    applyAfter(maps.addAfter, steps); //done
    applyBefore(maps.addBefore, steps); //todo
    applyReplace(maps.replace, steps); //done
    applyStart(maps.startWith, steps); //todo
    applyEnd(maps.endWith, steps); //todo
    return convertStepsToArray(steps);
};

function convertStepsToArray(stepObject) {
    var steps = [];
    _.forIn(stepObject, function (value, key) {
        if (_.isNil(value)) {
            throw new Error(util.format("Step with name %s was null", key));
        }
        steps.push(value);
    });
    return steps;
}

module.exports._applySkip = applySkip;
module.exports._applySkipIfExists = applySkipIfExists;
module.exports._applyAfter = applyAfter;
module.exports._applyReplace = applyReplace;
module.exports._applyStart = applyStart;
module.exports._applyEnd = applyEnd;

/**
 * Skips a named step in the middleware
 * @param {string[]|string} skip The step(s) to skip in the steps object.
 * @param {object} steps The steps object<commit_msg>adding missing private test property.<commit_after>'use strict';
var _ = require('lodash');
var util = require('util');
var paramNames = require('get-parameter-names');

module.exports = function applyMaps(maps, steps) {
    if (_.isNil(maps)) {
        return convertStepsToArray(steps);
    }
    if (!_.isObject(maps)) {
        throw new Error(util.format('The passed in map must be an object or null if no mapping is required. Type : "%s". Value : "%j"', typeof maps, maps));
    }
    applySkip(maps.skip, steps); //done
    applySkipIfExists(maps.skipIfExists, steps);//done
    applyAfter(maps.addAfter, steps); //done
    applyBefore(maps.addBefore, steps); //todo
    applyReplace(maps.replace, steps); //done
    applyStart(maps.startWith, steps); //todo
    applyEnd(maps.endWith, steps); //todo
    return convertStepsToArray(steps);
};

function convertStepsToArray(stepObject) {
    var steps = [];
    _.forIn(stepObject, function (value, key) {
        if (_.isNil(value)) {
            throw new Error(util.format("Step with name %s was null", key));
        }
        steps.push(value);
    });
    return steps;
}

module.exports._applySkip = applySkip;
module.exports._applySkipIfExists = applySkipIfExists;
module.exports._applyAfter = applyAfter;
module.exports._applyBefore = applyBefore;
module.exports._applyReplace = applyReplace;
module.exports._applyStart = applyStart;
module.exports._applyEnd = applyEnd;

/**
 * Skips a named step in the middleware
 * @param {string[]|string} skip The step(s) to skip in the steps object.
 * @param {object} steps The steps object
{'fraction_non_alphanumeric': 0.13344, 'fraction_numerical': 0.0, 'mean_word_length': 3.7435508345978756, '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': '5426926', 'n_tokens_mistral': 936, 'n_tokens_neox': 933, 'n_words': 253}