src/utils.js
/**
 * Removes all options of the passed `allArguments` array that are specified in the `argumentsToBeRemoved` array.
 *
 * @returns {Array<string>} An array with all arguments but excluding the filtered values specified by
 *          `argumentsToBeRemoved`.
 * @param {?Array<string>} allArguments An array containing all CLI arguments.
 * @param {?Array<{name: !string, hasValue: ?boolean}>} argumentsToBeRemoved An array that contains all argument names
 *        that must be removed from the `allArguments` array. If hasValue is set to `true`, the argument is assumed to
 *        have an additional value which will be removed as well.
 */
Removes all options of the passed `allArguments` array that are specified in the `argumentsToBeRemoved` array.
@returns {Array} An array with all arguments but excluding the filtered values specified by
`argumentsToBeRemoved`.
@param {?Array} allArguments An array containing all CLI arguments.
@param {?Array<{name: !string, hasValue: ?boolean}>} argumentsToBeRemoved An array that contains all argument names
that must be removed from the `allArguments` array. If hasValue is set to `true`, the argument is assumed to
have an additional value which will be removed as well.
Removes all options of the passed ` allArguments ` array that are specified in the ` argumentsToBeRemoved ` array . @returns { Array } An array with all arguments but excluding the filtered values specified by ` argumentsToBeRemoved ` . @param { ?Array } allArguments An array containing all CLI arguments . @param { ?Array< { name : !string hasValue : ?boolean } > } argumentsToBeRemoved An array that contains all argument names that must be removed from the ` allArguments ` array . If hasValue is set to ` true ` the argument is assumed to have an additional value which will be removed as well .
function removeArgumentsFromArgumentsArray (allArguments, argumentsToBeRemoved) {
    var result = [];
    if (!allArguments) return result;
    var innerArgumentsToBeRemoved = argumentsToBeRemoved || [];
    var i = 0;
    var getCurrentNameToBeRemoved = function (name) {
        var matches = innerArgumentsToBeRemoved.filter(function (n) {
            return n.name === name;
        });
        if (matches.length !== 0 && matches[0].hasValue != null) return matches[0];
        else if (matches.length !== 0) return {name: matches[0].name, hasValue: false};
        else return undefined;
    };
    while (i < allArguments.length) {
        var currentNameToBeRemoved = getCurrentNameToBeRemoved(allArguments[i]);
        if (currentNameToBeRemoved && currentNameToBeRemoved.hasValue) {
            i += 2;
        } else if (currentNameToBeRemoved) {
            ++i;
        } else {
            result.push(allArguments[i++]);
        }
    }
    return result;
}
function removeArgumentsFromArgumentsArray ( allArguments , argumentsToBeRemoved ) { var result = [ ] ; if ( ! allArguments ) return result ; var innerArgumentsToBeRemoved = argumentsToBeRemoved || [ ] ; var i = 0 ; var getCurrentNameToBeRemoved = function ( name ) { var matches = innerArgumentsToBeRemoved . filter ( function ( n ) { return n . name === name ; } ) ; if ( matches . length !== 0 && matches [ 0 ] . hasValue != null ) return matches [ 0 ] ; else if ( matches . length !== 0 ) return { name : matches [ 0 ] . name , hasValue : false } ; else return undefined ; } ; while ( i < allArguments . length ) { var currentNameToBeRemoved = getCurrentNameToBeRemoved ( allArguments [ i ] ) ; if ( currentNameToBeRemoved && currentNameToBeRemoved . hasValue ) { i += 2 ; } else if ( currentNameToBeRemoved ) { ++ i ; } else { result . push ( allArguments [ i ++ ] ) ; } } return result ; }
Removes all options of the passed `allArguments` array that are specified in the `argumentsToBeRemoved` array.
Removes all options of the passed ` allArguments ` array that are specified in the ` argumentsToBeRemoved ` array .