break up a pattern into its parts, pattern type and pattern name
@param  {String}       the shorthand partials syntax for a given pattern
@param  {Object}       the paths to be compared

@return {Array}        the pattern type and pattern name
491810
function (name, paths) {
    
    var patternBits = name.split("-");
    
    var i = 1;
    var c = patternBits.length;
    
    var patternType = patternBits[0];
    while ((paths[patternType] === undefined) && (i < c)) {
      patternType += "-"+patternBits[i];
      i++;
    }
    
    var pattern = name.slice(patternType.length+1,name.length);
    
    return [patternType, pattern];
    
  }
142823
function wrap(walker) {
  /**
   * @param {string} path
   * @param {RegExp|string|string[]} [pattern=/./]
   * @param {number} [depth=0]
   */
  return (path, pattern = /./, depth = 0) => {
    if (pattern instanceof RegExp) {
      // nothing to do
    } else if (typeof pattern === 'string') {
      pattern = RegExp(`${escapeRegexp(pattern)}$`, 'i');
    } else if (pattern instanceof Array) {
      pattern = `(?:${pattern.map(escapeRegexp).join('|')})$`;
      pattern = RegExp(pattern, 'i');
    } else {
      pattern = /./;
    }
    return walker(path, pattern, depth);
  };
}
60745
function convertPaths(path) {
  var pathTemplate = new URITemplate(path).parse(), // must call parse to populate parts
    expressPath = '';

  _.forEach(pathTemplate.parts, function (part) {
    switch (typeof part) {
      case 'string':
        if (part.length > 0) {
          expressPath += part;
        }
        break;
      case 'object':
        if (part.expression.length > 0 && part.expression.match(PATH_REGEX)) {
          expressPath += ':' + _.first(part.variables).name;
        }
        break;
      default:
      // TODO throw error
    }
  });

  return expressPath;
}
464213
function getComponentName(destPath) {
  const splitregex = new RegExp(`[\\${path.sep}-]+`);

  const parts = destPath
    .replace('.js', '')
    .split(splitregex)
    .map(part => part.charAt(0).toUpperCase() + part.substring(1));

  return parts.join('');
}
1243088
function fixPaths(paths) {
    return paths.map(path => {
        if (_.startsWith(path, '!./')) {
            return `!${path.substr(3)}`;
        } else if (_.startsWith(path, './')) {
            return path.substr(2);
        } else {
            return path;
        }
    });
}
1277392
function pattern () {
    var targ0 = typeof arguments[0];
    var targ1 = typeof arguments[1];
    var targ2 = typeof arguments[2];
  
    // Shared vars
    var matcherFn, patternObj, patternFn, patternStr, successFn, chain, tree, last;
  
    // pattern(matcherFn, chain)
    if (targ0 == "function" && (targ1 == "undefined" || targ1 == "object")) { 
      matcherFn = arguments[0];
      chain = arguments[1];
  
      // Throw an error if the supplied function does not have a match chain.
      if (!matcherFn.__matchChain) throw new Error("Not a matcher function");
  
      // Splice the chains together.
      if (chain) {
        chain = chain.clone();
        chain.last().next = matcherFn.__matchChain.clone();
      } else {
        chain = matcherFn.__matchChain.clone();
      }
  
      last = chain.pop();
      return matcher(last.patternFn, last.successFn, chain);
    }
  
    // pattern(patternObj, chain)
    else if (targ0 == "object" && (targ1 == "undefined" || targ1 == "object")) {
      patternObj = arguments[0];
      chain = arguments[1] ? arguments[1].clone() : null;
      for (patternStr in patternObj) {
        matcherFn = pattern(patternStr, patternObj[patternStr], chain);
        chain = matcherFn.__matchChain;
      }
      return matcherFn;
    }
  
    // pattern(patternFn, successFn, chain)
    else if (targ0 == "function" && targ1 == "function") {
      chain = arguments[2] ? arguments[2].clone() : null;
      return matcher(arguments[0], arguments[1], chain);
    }
  
    // pattern(patternStr, successFn, chain)
    else {
      patternStr = arguments[0];
      successFn = arguments[1];
      chain = arguments[2] ? arguments[2].clone() : null;
      patternFn = getOrCompile(patternStr);
      return matcher(patternFn, successFn, chain);
    }
  }
277230
function normalizePathParts(parts) {

        // IMPORTANT: It is assumed that parts[0] === "" because this method is used to
        // join an absolute path to a relative path
        var i;
        var len = 0;

        var numParts = parts.length;

        for (i = 0; i < numParts; i++) {
            var part = parts[i];

            if (part === '.') {
                // ignore parts with just "."
                /*
                // if the "." is at end of parts (e.g. ["a", "b", "."]) then trim it off
                if (i === numParts - 1) {
                    //len--;
                }
                */
            } else if (part === '..') {
                // overwrite the previous item by decrementing length
                len--;
            } else {
                // add this part to result and increment length
                parts[len] = part;
                len++;
            }
        }

        if (len === 1) {
            // if we end up with just one part that is empty string
            // (which can happen if input is ["", "."]) then return
            // string with just the leading slash
            return '/';
        } else if (len > 2) {
            // parts i s
            // ["", "a", ""]
            // ["", "a", "b", ""]
            if (parts[len - 1].length === 0) {
                // last part is an empty string which would result in trailing slash
                len--;
            }
        }

        // truncate parts to remove unused
        parts.length = len;
        return parts.join('/');
    }
1191380
function parsePath() {
  for (var _len3 = arguments.length, args = new Array(_len3), _key3 = 0; _key3 < _len3; _key3++) {
    args[_key3] = arguments[_key3];
  }

  var target = args[0],
      path = args[1],
      value = args[2];
  warning(typeof path === 'string', "The second parameter(".concat(JSON.stringify(path), ") of parsePath() must be a string."));
  var pathSymbols = (path.match(PATH_REGEXP) || []).map(function (s) {
    return s.replace(/\s/g, '');
  });
  var pathWords = path.split(PATH_REGEXP).map(function (s) {
    return s.trim();
  }).filter(function (item) {
    return item !== '';
  });
  var scope = target;

  try {
    if (args.length < 3) {
      for (var index = 0, len = pathWords.length; index < len; index++) {
        var word = executeWord(pathWords[index]);

        if (index + 1 === len) {
          return scope[word];
        }

        if (isUndefined(scope[word])) {
          break;
        }

        scope = scope[word];
      }
    } else {
      for (var _index = 0, length = pathWords.length; _index < length; _index++) {
        var _word = executeWord(pathWords[_index]);

        var nextWord = pathWords[_index + 1];
        var symbol = pathSymbols[_index];

        if (isUndefined(nextWord)) {
          scope[_word] = value;
          break;
        }

        switch (symbol) {
          case '].':
          case '.':
            scope = isUndefined(scope[_word]) ? scope[_word] = {} : scope[_word];
            break;

          case '][':
          case '[':
            var nextVarWord = executeWord(nextWord);
            scope = isUndefined(scope[_word]) ? scope[_word] = typeof nextVarWord === 'number' && nextVarWord >= 0 ? [] : {} : scope[_word];
            break;

          default:
            scope[_word] = value;
            break;
        }
      }
    }
  } catch (error) {
    warning(false, "The name '%s' of Field seems is not a legal expression.", path);
  }

  if (args.length > 2) {
    return target;
  }
}
260030
function createPatternVariations(pattern) {
    var lastCharIdx = pattern.length - 1,
        patternVariations = [pattern, '!' + pattern];

    if (pattern[lastCharIdx] === '/') {
        var unslashed = pattern.substring(0, lastCharIdx);

        patternVariations.push(unslashed);
        patternVariations.push('!' + unslashed);
    }

    return patternVariations;
}
199575
function(name, context, partials, indent) {
      var partial = partials[name];

      if (!partial) {
        return '';
      }

      if (this.c && typeof partial == 'string') {
        partial = this.c.compile(partial, this.options);
      }

      return partial.ri(context, partials, indent);
    }
1171585
function allPaths (splitPath, partialPath, finalPaths, i) {
  i = i || 0
  finalPaths = finalPaths || []
  partialPath = (partialPath || '') + splitPath[i]

  if (i >= splitPath.length - 1) {
    finalPaths.push(partialPath)
  } else {
    allPaths(splitPath, partialPath + '/', finalPaths, i + 1)
    allPaths(splitPath, partialPath + '\\', finalPaths, i + 1)
  }

  return finalPaths
}
529363
function _gpfPathMatch (pattern, path) {
    var parts = _gpfPathDecompose(path),
        matchers = _gpfPathMatchCompilePatterns(pattern),
        scope = {
            parts: parts
        };
    matchers.every(_gpfPathMatchApply, scope);
    return scope.result;
}
1172450
function routeIsActive(pathname, routes, params) {
  var remainingPathname = pathname,
      paramNames = [],
      paramValues = [];

  // for...of would work here but it's probably slower post-transpilation.
  for (var i = 0, len = routes.length; i < len; ++i) {
    var route = routes[i];
    var pattern = route.path || '';

    if (pattern.charAt(0) === '/') {
      remainingPathname = pathname;
      paramNames = [];
      paramValues = [];
    }

    if (remainingPathname !== null && pattern) {
      var matched = (0, _PatternUtils.matchPattern)(pattern, remainingPathname);
      if (matched) {
        remainingPathname = matched.remainingPathname;
        paramNames = [].concat(paramNames, matched.paramNames);
        paramValues = [].concat(paramValues, matched.paramValues);
      } else {
        remainingPathname = null;
      }

      if (remainingPathname === '') {
        // We have an exact match on the route. Just check that all the params
        // match.
        // FIXME: This doesn't work on repeated params.
        return paramNames.every(function (paramName, index) {
          return String(paramValues[index]) === String(params[paramName]);
        });
      }
    }
  }

  return false;
}
1028827
function stripCommonPath(paths) {
  var prefix = commonPrefix(paths);
  var prefixLength = prefix.lastIndexOf('/') + 1;

  return paths.map(function(str) {
    return str.slice(prefixLength);
  });
}
1263920
def route(method, pattern, handler=None):
    
    if handler is None:
        return partial(route, method, pattern)
    return routes.append(method, pattern, handler)
421207
function distinguishPaths(paths) {
    paths = Array.isArray(paths) ? paths : [paths];
    var result = {
      directories: [],
      files: []
    };
    paths.forEach(function(name) {
      if (fs.statSync(name).isDirectory()) {
        result.directories.push(name);
      } else {
        result.files.push(name);
      }
    });
    return result;
  }
710047
function processPattern({ cwd = process.cwd(), ext } = {}) {
  let suffix = '/**';

  const extensions = (ext || ['html'])
    .map(_ext => (_ext.charAt(0) === '.' ? _ext.substr(1) : _ext));

  if (extensions.length === 1) {
    suffix = `${suffix}/*.${extensions[0]}`;
  } else {
    suffix = `${suffix}/*.{${extensions.join(',')}}`;
  }

  return function _processPattern(pattern) {
    const resolvedPath = path.resolve(cwd, pattern);

    if (!(fs.existsSync(resolvedPath) &&
          fs.statSync(resolvedPath).isDirectory())
    ) {
      return pattern;
    }

    return pattern.replace(/[\/\\]?$/, suffix);
  };
}