function transformMatchCall (context: ConversionContext, path: NodePath) {
  // the first arguments are the input, the last should be an array of clauses
  const args = path.get('arguments');
  if (args.length < 2) {
    // must have at least two arguments, bail out
    return;
  }
  const tail = args.pop();
  if (!tail.isArrayExpression()) {
    // last arg must be an array of clauses, bail out
    return;
  }

  const clauses = tail.get('elements');

  if (!clauses.length) {
    // empty array of clauses, bail out.
    return;
  }

  const collected = collectClauses(context, clauses);
  if (!collected) {
    return;
  }
  const [collectedParams, collectedBlocks, errorClause] = collected;
  const pattern = makePattern(context, path, collectedParams, collectedBlocks, errorClause);
  if (pattern) {
    context.replacePath(path, t.callExpression(pattern, args.map(arg => arg.node)));
  }
}
function transformMatchCall (context: ConversionContext, path: NodePath) {
  
  const args = path.get('arguments');
  if (args.length < 2) {
    
    return;
  }
  const tail = args.pop();
  if (!tail.isArrayExpression()) {
    
    return;
  }

  const clauses = tail.get('elements');

  if (!clauses.length) {
    
    return;
  }

  const collected = collectClauses(context, clauses);
  if (!collected) {
    return;
  }
  const [collectedParams, collectedBlocks, errorClause] = collected;
  const pattern = makePattern(context, path, collectedParams, collectedBlocks, errorClause);
  if (pattern) {
    context.replacePath(path, t.callExpression(pattern, args.map(arg => arg.node)));
  }
}
function transformMatchCall ( context : ConversionContext , path : NodePath ) { // the first arguments are the input, the last should be an array of clauses const args = path . get ( 'arguments' ) ; if ( args . length < 2 ) { // must have at least two arguments, bail out return ; } const tail = args . pop ( ) ; if ( ! tail . isArrayExpression ( ) ) { // last arg must be an array of clauses, bail out return ; } const clauses = tail . get ( 'elements' ) ; if ( ! clauses . length ) { // empty array of clauses, bail out. return ; } const collected = collectClauses ( context , clauses ) ; if ( ! collected ) { return ; } const [ collectedParams , collectedBlocks , errorClause ] = collected ; const pattern = makePattern ( context , path , collectedParams , collectedBlocks , errorClause ) ; if ( pattern ) { context . replacePath ( path , t . callExpression ( pattern , args . map ( arg => arg . node ) ) ) ; } }
Transform a call to `t.match()` into an optimized version if possible.
Transform a call to t . match () into an optimized version if possible .