matches.js
function matcher (patternFn, successFn, chain) {
    var matcherObj = new Matcher(patternFn, successFn);
  
    // If a chain was provided, add the new matcher to the end of the chain.
    if (chain) {
      chain.last().next = matcherObj;
    } else {
      chain = matcherObj;
    }
  
    var fn = function () {
      // This seems like an odd optimization, but manually copying the
      // arguments object over to an array instead of calling `slice` can
      // speed up dispatch time 2-3x.
      var args = [], i = 0, len = arguments.length;
      for (; i < len; i++) args[i] = arguments[i];
      return chain.match(args, this);
    };
  
    fn.alt = function () {
      var args = slice.call(arguments);
      args.push(chain);
      return pattern.apply(null, args);
    };
  
    fn.__matchChain = chain;
  
    return fn;
  }
function matcher (patternFn, successFn, chain) {
    var matcherObj = new Matcher(patternFn, successFn);
  
    // If a chain was provided, add the new matcher to the end of the chain.
    if (chain) {
      chain.last().next = matcherObj;
    } else {
      chain = matcherObj;
    }
  
    var fn = function () {
      // This seems like an odd optimization, but manually copying the
      // arguments object over to an array instead of calling `slice` can
      // speed up dispatch time 2-3x.
      var args = [], i = 0, len = arguments.length;
      for (; i < len; i++) args[i] = arguments[i];
      return chain.match(args, this);
    };
  
    fn.alt = function () {
      var args = slice.call(arguments);
      args.push(chain);
      return pattern.apply(null, args);
    };
  
    fn.__matchChain = chain;
  
    return fn;
  }
function matcher ( patternFn , successFn , chain ) { var matcherObj = new Matcher ( patternFn , successFn ) ; // If a chain was provided, add the new matcher to the end of the chain. if ( chain ) { chain . last ( ) . next = matcherObj ; } else { chain = matcherObj ; } var fn = function ( ) { // This seems like an odd optimization, but manually copying the // arguments object over to an array instead of calling `slice` can // speed up dispatch time 2-3x. var args = [ ] , i = 0 , len = arguments . length ; for ( ; i < len ; i ++ ) args [ i ] = arguments [ i ] ; return chain . match ( args , this ) ; } ; fn . alt = function ( ) { var args = slice . call ( arguments ) ; args . push ( chain ) ; return pattern . apply ( null , args ) ; } ; fn . __matchChain = chain ; return fn ; }
Creates a function that tries a match and executes the given fn if successful. If not it tries subsequent patterns.
Creates a function that tries a match and executes the given fn if successful . If not it tries subsequent patterns .