function $f5e295eb003165a8$var$tokensToFunction(tokens) {
    // Compile all the tokens into regexps.
    var matches = new Array(tokens.length);
    // Compile all the patterns before compilation.
    for(var i1 = 0; i1 < tokens.length; i1++)if (typeof tokens[i1] === 'object') matches[i1] = new RegExp('^(?:' + tokens[i1].pattern + ')$');
    return function(data, options) {
        var path = '';
        var encode = options && options.encode || encodeURIComponent;
        for(var i = 0; i < tokens.length; i++){
            var token = tokens[i];
            if (typeof token === 'string') {
                path += token;
                continue;
            }
            var value = data ? data[token.name] : undefined;
            var segment;
            if (Array.isArray(value)) {
                if (!token.repeat) throw new TypeError('Expected "' + token.name + '" to not repeat, but got array');
                if (value.length === 0) {
                    if (token.optional) continue;
                    throw new TypeError('Expected "' + token.name + '" to not be empty');
                }
                for(var j = 0; j < value.length; j++){
                    segment = encode(value[j], token);
                    if (!matches[i].test(segment)) throw new TypeError('Expected all "' + token.name + '" to match "' + token.pattern + '"');
                    path += (j === 0 ? token.prefix : token.delimiter) + segment;
                }
                continue;
            }
            if (typeof value === 'string' || typeof value === 'number' || typeof value === 'boolean') {
                segment = encode(String(value), token);
                if (!matches[i].test(segment)) throw new TypeError('Expected "' + token.name + '" to match "' + token.pattern + '", but got "' + segment + '"');
                path += token.prefix + segment;
                continue;
            }
            if (token.optional) {
                // Prepend partial segment prefixes.
                if (token.partial) path += token.prefix;
                continue;
            }
            throw new TypeError('Expected "' + token.name + '" to be ' + (token.repeat ? 'an array' : 'a string'));
        }
        return path;
    };
}
/**
 * Expose a method for transforming tokens into the path function.
 */
Expose a method for transforming tokens into the path function.
Expose a method for transforming tokens into the path function .
function $f5e295eb003165a8$var$tokensToFunction(tokens) {
    var matches = new Array(tokens.length);
    for(var i1 = 0; i1 < tokens.length; i1++)if (typeof tokens[i1] === 'object') matches[i1] = new RegExp('^(?:' + tokens[i1].pattern + ')$');
    return function(data, options) {
        var path = '';
        var encode = options && options.encode || encodeURIComponent;
        for(var i = 0; i < tokens.length; i++){
            var token = tokens[i];
            if (typeof token === 'string') {
                path += token;
                continue;
            }
            var value = data ? data[token.name] : undefined;
            var segment;
            if (Array.isArray(value)) {
                if (!token.repeat) throw new TypeError('Expected "' + token.name + '" to not repeat, but got array');
                if (value.length === 0) {
                    if (token.optional) continue;
                    throw new TypeError('Expected "' + token.name + '" to not be empty');
                }
                for(var j = 0; j < value.length; j++){
                    segment = encode(value[j], token);
                    if (!matches[i].test(segment)) throw new TypeError('Expected all "' + token.name + '" to match "' + token.pattern + '"');
                    path += (j === 0 ? token.prefix : token.delimiter) + segment;
                }
                continue;
            }
            if (typeof value === 'string' || typeof value === 'number' || typeof value === 'boolean') {
                segment = encode(String(value), token);
                if (!matches[i].test(segment)) throw new TypeError('Expected "' + token.name + '" to match "' + token.pattern + '", but got "' + segment + '"');
                path += token.prefix + segment;
                continue;
            }
            if (token.optional) {
                if (token.partial) path += token.prefix;
                continue;
            }
            throw new TypeError('Expected "' + token.name + '" to be ' + (token.repeat ? 'an array' : 'a string'));
        }
        return path;
    };
}
function $f5e295eb003165a8$var$tokensToFunction ( tokens ) { var matches = new Array ( tokens . length ) ; for ( var i1 = 0 ; i1 < tokens . length ; i1 ++ ) if ( typeof tokens [ i1 ] === 'object' ) matches [ i1 ] = new RegExp ( '^(?:' + tokens [ i1 ] . pattern + ')$' ) ; return function ( data , options ) { var path = '' ; var encode = options && options . encode || encodeURIComponent ; for ( var i = 0 ; i < tokens . length ; i ++ ) { var token = tokens [ i ] ; if ( typeof token === 'string' ) { path += token ; continue ; } var value = data ? data [ token . name ] : undefined ; var segment ; if ( Array . isArray ( value ) ) { if ( ! token . repeat ) throw new TypeError ( 'Expected "' + token . name + '" to not repeat, but got array' ) ; if ( value . length === 0 ) { if ( token . optional ) continue ; throw new TypeError ( 'Expected "' + token . name + '" to not be empty' ) ; } for ( var j = 0 ; j < value . length ; j ++ ) { segment = encode ( value [ j ] , token ) ; if ( ! matches [ i ] . test ( segment ) ) throw new TypeError ( 'Expected all "' + token . name + '" to match "' + token . pattern + '"' ) ; path += ( j === 0 ? token . prefix : token . delimiter ) + segment ; } continue ; } if ( typeof value === 'string' || typeof value === 'number' || typeof value === 'boolean' ) { segment = encode ( String ( value ) , token ) ; if ( ! matches [ i ] . test ( segment ) ) throw new TypeError ( 'Expected "' + token . name + '" to match "' + token . pattern + '", but got "' + segment + '"' ) ; path += token . prefix + segment ; continue ; } if ( token . optional ) { if ( token . partial ) path += token . prefix ; continue ; } throw new TypeError ( 'Expected "' + token . name + '" to be ' + ( token . repeat ? 'an array' : 'a string' ) ) ; } return path ; } ; }
Expose a method for transforming tokens into the path function.
Expose a method for transforming tokens into the path function .
// Compile all the tokens into regexps. // Compile all the patterns before compilation. // Prepend partial segment prefixes.