code: function tokensToFunction (tokens) {
      // Compile all the tokens into regexps.
      var matches = new Array(tokens.length);
  
      // Compile all the patterns before compilation.
      for (var i = 0; i < tokens.length; i++) {
        if (typeof tokens[i] === 'object') {
          matches[i] = new RegExp('^(?:' + tokens[i].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) { continue }
  
          throw new TypeError('Expected "' + token.name + '" to be ' + (token.repeat ? 'an array' : 'a string'))
        }
  
        return path
      }
    }
docs: Expose a method for transforming tokens into the path function.