lib/utils.js
function expandPropertyNameGlobs(object, globPatterns) {
    const result = [];

    if (!globPatterns.length)
        return result;


    const arrayGroupPattern = globPatterns[0];
    const indexOfArrayGroup = arrayGroupPattern.indexOf('[]');
    if (indexOfArrayGroup !== -1) {
        const {arrayProp, arrayPropName} = getArrayProperty(object, arrayGroupPattern, indexOfArrayGroup);

        arrayProp.forEach((v, i) => {
            const pp = `${arrayPropName}[${i}]`;
            const propertyGroup = [];
            for (let i = 1; i < globPatterns.length; i++) {
                const pattern = `${pp}.${globPatterns[i]}`;
                propertyGroup.push(pattern);
            }
            result.push(propertyGroup);
        });
        return result;
    }

    for (let pattern of globPatterns) {
        let indexOfGlob = pattern.indexOf('*');
        if (indexOfGlob === -1) {
            result.push(pattern);
        }
        else {
            const {arrayProp, arrayPropName} = getArrayProperty(object, pattern, indexOfGlob);

            arrayProp.forEach((v, i) => {
                const pp = `${arrayPropName}[${i}]`;
                if (indexOfGlob < pattern.length - 1)
                    result.push(pp + pattern.substring(indexOfGlob + 1));
                else if (typeof v === 'object')
                    Object.getOwnPropertyNames(v).forEach(n => result.push(`${pp}.${n}`));
                else
                    result.push(pp);
            });
        }
    }

    return result;
}
function expandPropertyNameGlobs(object, globPatterns) {
    const result = [];

    if (!globPatterns.length)
        return result;


    const arrayGroupPattern = globPatterns[0];
    const indexOfArrayGroup = arrayGroupPattern.indexOf('[]');
    if (indexOfArrayGroup !== -1) {
        const {arrayProp, arrayPropName} = getArrayProperty(object, arrayGroupPattern, indexOfArrayGroup);

        arrayProp.forEach((v, i) => {
            const pp = `${arrayPropName}[${i}]`;
            const propertyGroup = [];
            for (let i = 1; i < globPatterns.length; i++) {
                const pattern = `${pp}.${globPatterns[i]}`;
                propertyGroup.push(pattern);
            }
            result.push(propertyGroup);
        });
        return result;
    }

    for (let pattern of globPatterns) {
        let indexOfGlob = pattern.indexOf('*');
        if (indexOfGlob === -1) {
            result.push(pattern);
        }
        else {
            const {arrayProp, arrayPropName} = getArrayProperty(object, pattern, indexOfGlob);

            arrayProp.forEach((v, i) => {
                const pp = `${arrayPropName}[${i}]`;
                if (indexOfGlob < pattern.length - 1)
                    result.push(pp + pattern.substring(indexOfGlob + 1));
                else if (typeof v === 'object')
                    Object.getOwnPropertyNames(v).forEach(n => result.push(`${pp}.${n}`));
                else
                    result.push(pp);
            });
        }
    }

    return result;
}
function expandPropertyNameGlobs ( object , globPatterns ) { const result = [ ] ; if ( ! globPatterns . length ) return result ; const arrayGroupPattern = globPatterns [ 0 ] ; const indexOfArrayGroup = arrayGroupPattern . indexOf ( '[]' ) ; if ( indexOfArrayGroup !== - 1 ) { const { arrayProp , arrayPropName } = getArrayProperty ( object , arrayGroupPattern , indexOfArrayGroup ) ; arrayProp . forEach ( ( v , i ) => { const pp = ` ${ arrayPropName } ${ i } ` ; const propertyGroup = [ ] ; for ( let i = 1 ; i < globPatterns . length ; i ++ ) { const pattern = ` ${ pp } ${ globPatterns [ i ] } ` ; propertyGroup . push ( pattern ) ; } result . push ( propertyGroup ) ; } ) ; return result ; } for ( let pattern of globPatterns ) { let indexOfGlob = pattern . indexOf ( '*' ) ; if ( indexOfGlob === - 1 ) { result . push ( pattern ) ; } else { const { arrayProp , arrayPropName } = getArrayProperty ( object , pattern , indexOfGlob ) ; arrayProp . forEach ( ( v , i ) => { const pp = ` ${ arrayPropName } ${ i } ` ; if ( indexOfGlob < pattern . length - 1 ) result . push ( pp + pattern . substring ( indexOfGlob + 1 ) ) ; else if ( typeof v === 'object' ) Object . getOwnPropertyNames ( v ) . forEach ( n => result . push ( ` ${ pp } ${ n } ` ) ) ; else result . push ( pp ) ; } ) ; } } return result ; }
Takes an array of property patterns and expands any glob pattern it finds
based on the provided object.
@private
@param object
@param globPatterns
@returns {Array}
Takes an array of property patterns and expands any glob pattern it finds based on the provided object .