index.js
function (config, base, parent) {
        var key,
            sub,
            find,
            item;
        base = base || config;
        parent = parent || {ref: config, key: null};
        var subFlag = false;

        for (key in config) {
            if (config.hasOwnProperty(key)) {
                // If the value is an "Object" or an "Array" drill into it

                if (isIterable(config[key])) {
                    // parent param {ref: config, key: key} is a recursion
                    // pointer that needed only when replacing "keys"
                    subFlag = this._applySubstitutions(config[key], base, {ref: config, key: key}) || subFlag;

                } else {
                    // Test if the key is a "substitution" key
                    sub = SUBMATCH.exec(key);
                    if (sub && (sub[0] === key)) {
                        subFlag = true;
                        // Pull out the key to "find"
                        find = extract(base, sub[1], null);

                        if (isA(find, Object)) {
                            // Remove the "substitution" key
                            delete config[key];

                            // Add the keys founds
                            // This should be inline at the point where the "substitution" key was.
                            // Currently they will be added out of order on the end of the map.
                            for (item in find) {
                                if (find.hasOwnProperty(item)) {
                                    if (!parent.ref[parent.key]) {
                                        parent.ref[item] = find[item];
                                    } else {
                                        parent.ref[parent.key][item] = find[item];
                                    }
                                }
                            }
                        } else {
                            config[key] = '--YCB-SUBSTITUTION-ERROR--';
                        }

                    } else if (SUBMATCH.test(config[key])) {
                        subFlag = true;
                        // Test if the value is a "substitution" value
                        // We have a match so lets use it
                        sub = SUBMATCH.exec(config[key]);
                        // Pull out the key to "find"
                        find = sub[1];
                        // First see if it is the whole value
                        if (sub[0] === config[key]) {
                            // Replace the whole value with the value found by the sub string
                            find = extract(base, find, null);
                            // If we have an array in an array do it "special like"
                            if (isA(find, Array) && isA(config, Array)) {
                                // This has to be done on the parent or the reference is lost
                                // The whole {ref: config, key: key} is needed only when replacing "keys"
                                parent.ref[parent.key] = config.slice(0, parseInt(key, 10))
                                    .concat(find)
                                    .concat(config.slice(parseInt(key, 10) + 1));
                            } else {
                                config[key] = find;
                            }
                        } else {
                            // If not it's just part of the whole value
                            config[key] = config[key]
                                .replace(SUBMATCHES, replacer(base));
                        }
                    }
                }
            }
        }
        return subFlag;
    }
function (config, base, parent) {
        var key,
            sub,
            find,
            item;
        base = base || config;
        parent = parent || {ref: config, key: null};
        var subFlag = false;

        for (key in config) {
            if (config.hasOwnProperty(key)) {
                // If the value is an "Object" or an "Array" drill into it

                if (isIterable(config[key])) {
                    // parent param {ref: config, key: key} is a recursion
                    // pointer that needed only when replacing "keys"
                    subFlag = this._applySubstitutions(config[key], base, {ref: config, key: key}) || subFlag;

                } else {
                    // Test if the key is a "substitution" key
                    sub = SUBMATCH.exec(key);
                    if (sub && (sub[0] === key)) {
                        subFlag = true;
                        // Pull out the key to "find"
                        find = extract(base, sub[1], null);

                        if (isA(find, Object)) {
                            // Remove the "substitution" key
                            delete config[key];

                            // Add the keys founds
                            // This should be inline at the point where the "substitution" key was.
                            // Currently they will be added out of order on the end of the map.
                            for (item in find) {
                                if (find.hasOwnProperty(item)) {
                                    if (!parent.ref[parent.key]) {
                                        parent.ref[item] = find[item];
                                    } else {
                                        parent.ref[parent.key][item] = find[item];
                                    }
                                }
                            }
                        } else {
                            config[key] = '--YCB-SUBSTITUTION-ERROR--';
                        }

                    } else if (SUBMATCH.test(config[key])) {
                        subFlag = true;
                        // Test if the value is a "substitution" value
                        // We have a match so lets use it
                        sub = SUBMATCH.exec(config[key]);
                        // Pull out the key to "find"
                        find = sub[1];
                        // First see if it is the whole value
                        if (sub[0] === config[key]) {
                            // Replace the whole value with the value found by the sub string
                            find = extract(base, find, null);
                            // If we have an array in an array do it "special like"
                            if (isA(find, Array) && isA(config, Array)) {
                                // This has to be done on the parent or the reference is lost
                                // The whole {ref: config, key: key} is needed only when replacing "keys"
                                parent.ref[parent.key] = config.slice(0, parseInt(key, 10))
                                    .concat(find)
                                    .concat(config.slice(parseInt(key, 10) + 1));
                            } else {
                                config[key] = find;
                            }
                        } else {
                            // If not it's just part of the whole value
                            config[key] = config[key]
                                .replace(SUBMATCHES, replacer(base));
                        }
                    }
                }
            }
        }
        return subFlag;
    }
function ( config , base , parent ) { var key , sub , find , item ; base = base || config ; parent = parent || { ref : config , key : null } ; var subFlag = false ; for ( key in config ) { if ( config . hasOwnProperty ( key ) ) { // If the value is an "Object" or an "Array" drill into it if ( isIterable ( config [ key ] ) ) { // parent param {ref: config, key: key} is a recursion // pointer that needed only when replacing "keys" subFlag = this . _applySubstitutions ( config [ key ] , base , { ref : config , key : key } ) || subFlag ; } else { // Test if the key is a "substitution" key sub = SUBMATCH . exec ( key ) ; if ( sub && ( sub [ 0 ] === key ) ) { subFlag = true ; // Pull out the key to "find" find = extract ( base , sub [ 1 ] , null ) ; if ( isA ( find , Object ) ) { // Remove the "substitution" key delete config [ key ] ; // Add the keys founds // This should be inline at the point where the "substitution" key was. // Currently they will be added out of order on the end of the map. for ( item in find ) { if ( find . hasOwnProperty ( item ) ) { if ( ! parent . ref [ parent . key ] ) { parent . ref [ item ] = find [ item ] ; } else { parent . ref [ parent . key ] [ item ] = find [ item ] ; } } } } else { config [ key ] = '--YCB-SUBSTITUTION-ERROR--' ; } } else if ( SUBMATCH . test ( config [ key ] ) ) { subFlag = true ; // Test if the value is a "substitution" value // We have a match so lets use it sub = SUBMATCH . exec ( config [ key ] ) ; // Pull out the key to "find" find = sub [ 1 ] ; // First see if it is the whole value if ( sub [ 0 ] === config [ key ] ) { // Replace the whole value with the value found by the sub string find = extract ( base , find , null ) ; // If we have an array in an array do it "special like" if ( isA ( find , Array ) && isA ( config , Array ) ) { // This has to be done on the parent or the reference is lost // The whole {ref: config, key: key} is needed only when replacing "keys" parent . ref [ parent . key ] = config . slice ( 0 , parseInt ( key , 10 ) ) . concat ( find ) . concat ( config . slice ( parseInt ( key , 10 ) + 1 ) ) ; } else { config [ key ] = find ; } } else { // If not it's just part of the whole value config [ key ] = config [ key ] . replace ( SUBMATCHES , replacer ( base ) ) ; } } } } } return subFlag ; }
This is a first pass at hairball of a function.

@private
@method _applySubstitutions
@param config {object}
@param base {object}
@param parent {object}
@return {boolean}
This is a first pass at hairball of a function .