lost+found/src/params.js
function (parameters, argumentsToParse) {
                var
                    result = {},
                    len,
                    idx,
                    argument,
                    parameter,
                    name,
                    lastNonPrefixIdx = 0;
                parameters = gpf.Parameter.create(parameters);
                len = argumentsToParse.length;
                for (idx = 0; idx < len; ++idx) {
                    // Check if a prefix was used and find parameter
                    argument = this.getPrefixValuePair(argumentsToParse[idx]);
                    if (argument instanceof Array) {
                        parameter = this.getOnPrefix(parameters, argument[0]);
                        argument = argument[1];
                    } else {
                        parameter = this.getOnPrefix(parameters,
                            lastNonPrefixIdx);
                        lastNonPrefixIdx = parameters.indexOf(parameter) + 1;
                    }
                    // If no parameter corresponds, ignore
                    if (!parameter) {
                        // TODO maybe an error might be more appropriate
                        continue;
                    }
                    // Sometimes, the prefix might be used without value
                    if (undefined === argument) {
                        if ("boolean" === parameter._type) {
                            argument = !parameter._defaultValue;
                        } else {
                            // Nothing to do with it
                            // TODO maybe an error might be more appropriate
                            continue;
                        }
                    }
                    // Convert the value to match the type
                    // TODO change when type will be an object
                    argument = gpf.value(argument, parameter._defaultValue,
                        parameter._type);
                    // Assign the corresponding member of the result object
                    name = parameter._name;
                    if (parameter._multiple) {
                        if (undefined === result[name]) {
                            result[name] = [];
                        }
                        result[name].push(argument);
                        if (parameter._prefix === "") {
                            --lastNonPrefixIdx;
                        }

                    } else {
                        // The last one wins
                        result[name] = argument;
                    }
                }
                this._finalizeParse(parameters, result);
                return result;
            }
function (parameters, argumentsToParse) {
                var
                    result = {},
                    len,
                    idx,
                    argument,
                    parameter,
                    name,
                    lastNonPrefixIdx = 0;
                parameters = gpf.Parameter.create(parameters);
                len = argumentsToParse.length;
                for (idx = 0; idx < len; ++idx) {
                    // Check if a prefix was used and find parameter
                    argument = this.getPrefixValuePair(argumentsToParse[idx]);
                    if (argument instanceof Array) {
                        parameter = this.getOnPrefix(parameters, argument[0]);
                        argument = argument[1];
                    } else {
                        parameter = this.getOnPrefix(parameters,
                            lastNonPrefixIdx);
                        lastNonPrefixIdx = parameters.indexOf(parameter) + 1;
                    }
                    // If no parameter corresponds, ignore
                    if (!parameter) {
                        // TODO maybe an error might be more appropriate
                        continue;
                    }
                    // Sometimes, the prefix might be used without value
                    if (undefined === argument) {
                        if ("boolean" === parameter._type) {
                            argument = !parameter._defaultValue;
                        } else {
                            // Nothing to do with it
                            // TODO maybe an error might be more appropriate
                            continue;
                        }
                    }
                    // Convert the value to match the type
                    // TODO change when type will be an object
                    argument = gpf.value(argument, parameter._defaultValue,
                        parameter._type);
                    // Assign the corresponding member of the result object
                    name = parameter._name;
                    if (parameter._multiple) {
                        if (undefined === result[name]) {
                            result[name] = [];
                        }
                        result[name].push(argument);
                        if (parameter._prefix === "") {
                            --lastNonPrefixIdx;
                        }

                    } else {
                        // The last one wins
                        result[name] = argument;
                    }
                }
                this._finalizeParse(parameters, result);
                return result;
            }
function ( parameters , argumentsToParse ) { var result = { } , len , idx , argument , parameter , name , lastNonPrefixIdx = 0 ; parameters = gpf . Parameter . create ( parameters ) ; len = argumentsToParse . length ; for ( idx = 0 ; idx < len ; ++ idx ) { // Check if a prefix was used and find parameter argument = this . getPrefixValuePair ( argumentsToParse [ idx ] ) ; if ( argument instanceof Array ) { parameter = this . getOnPrefix ( parameters , argument [ 0 ] ) ; argument = argument [ 1 ] ; } else { parameter = this . getOnPrefix ( parameters , lastNonPrefixIdx ) ; lastNonPrefixIdx = parameters . indexOf ( parameter ) + 1 ; } // If no parameter corresponds, ignore if ( ! parameter ) { // TODO maybe an error might be more appropriate continue ; } // Sometimes, the prefix might be used without value if ( undefined === argument ) { if ( "boolean" === parameter . _type ) { argument = ! parameter . _defaultValue ; } else { // Nothing to do with it // TODO maybe an error might be more appropriate continue ; } } // Convert the value to match the type // TODO change when type will be an object argument = gpf . value ( argument , parameter . _defaultValue , parameter . _type ) ; // Assign the corresponding member of the result object name = parameter . _name ; if ( parameter . _multiple ) { if ( undefined === result [ name ] ) { result [ name ] = [ ] ; } result [ name ] . push ( argument ) ; if ( parameter . _prefix === "" ) { -- lastNonPrefixIdx ; } } else { // The last one wins result [ name ] = argument ; } } this . _finalizeParse ( parameters , result ) ; return result ; }
Parse the arguments and return an object with the
recognized parameters. Throws an error if required parameters
are missing.

@param {gpf.Parameter[]|Object[]} parameters
@param {String[]} argumentsToParse
@return {Object}
Parse the arguments and return an object with the recognized parameters . Throws an error if required parameters are missing .