src/parse-tree/index.js
function getHashesFromRoute(route, depth, hashes, hash) {
    /*eslint-disable no-func-assign, no-param-reassign*/
    depth = depth || 0;
    hashes = hashes || [];
    hash = hash || [];
    /*eslint-enable no-func-assign, no-param-reassign*/

    var routeValue = route[depth];
    var isArray = Array.isArray(routeValue);
    var length = isArray && routeValue.length || 0;
    var idx = 0;
    var value;

    if (typeof routeValue === 'object' && !isArray) {
        value = routeValue.type;
    }

    else if (!isArray) {
        value = routeValue;
    }

    do {
        if (isArray) {
            value = routeValue[idx];
        }

        if (value === Keys.integers || value === Keys.ranges) {
            hash[depth] = '__I__';
        }

        else if (value === Keys.keys) {
            hash[depth] ='__K__';
        }

        else {
            hash[depth] = value;
        }

        // recurse down the routed token
        if (depth + 1 !== route.length) {
            getHashesFromRoute(route, depth + 1, hashes, hash);
        }

        // Or just add it to hashes
        else {
            hashes.push(cloneArray(hash));
        }
    } while (isArray && ++idx < length);

    return hashes;
}
function getHashesFromRoute(route, depth, hashes, hash) {
    /*eslint-disable no-func-assign, no-param-reassign*/
    depth = depth || 0;
    hashes = hashes || [];
    hash = hash || [];
    /*eslint-enable no-func-assign, no-param-reassign*/

    var routeValue = route[depth];
    var isArray = Array.isArray(routeValue);
    var length = isArray && routeValue.length || 0;
    var idx = 0;
    var value;

    if (typeof routeValue === 'object' && !isArray) {
        value = routeValue.type;
    }

    else if (!isArray) {
        value = routeValue;
    }

    do {
        if (isArray) {
            value = routeValue[idx];
        }

        if (value === Keys.integers || value === Keys.ranges) {
            hash[depth] = '__I__';
        }

        else if (value === Keys.keys) {
            hash[depth] ='__K__';
        }

        else {
            hash[depth] = value;
        }

        // recurse down the routed token
        if (depth + 1 !== route.length) {
            getHashesFromRoute(route, depth + 1, hashes, hash);
        }

        // Or just add it to hashes
        else {
            hashes.push(cloneArray(hash));
        }
    } while (isArray && ++idx < length);

    return hashes;
}
function getHashesFromRoute ( route , depth , hashes , hash ) { /*eslint-disable no-func-assign, no-param-reassign*/ depth = depth || 0 ; hashes = hashes || [ ] ; hash = hash || [ ] ; /*eslint-enable no-func-assign, no-param-reassign*/ var routeValue = route [ depth ] ; var isArray = Array . isArray ( routeValue ) ; var length = isArray && routeValue . length || 0 ; var idx = 0 ; var value ; if ( typeof routeValue === 'object' && ! isArray ) { value = routeValue . type ; } else if ( ! isArray ) { value = routeValue ; } do { if ( isArray ) { value = routeValue [ idx ] ; } if ( value === Keys . integers || value === Keys . ranges ) { hash [ depth ] = '__I__' ; } else if ( value === Keys . keys ) { hash [ depth ] = '__K__' ; } else { hash [ depth ] = value ; } // recurse down the routed token if ( depth + 1 !== route . length ) { getHashesFromRoute ( route , depth + 1 , hashes , hash ) ; } // Or just add it to hashes else { hashes . push ( cloneArray ( hash ) ) ; } } while ( isArray && ++ idx < length ) ; return hashes ; }
creates a hash of the virtual path where integers and ranges
will collide but everything else is unique.
creates a hash of the virtual path where integers and ranges will collide but everything else is unique .