How to use the babylon.tokTypes.comma function in babylon

To help you get started, we’ve selected a few babylon examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github ringcentral / ringcentral-js-widgets / packages / locale-loader / lib / getRawData / index.js View on Github external
} while (token.type !== tokTypes.colon);
  const valueArray = [];
  const valueStart = idx + 1;
  let valueEnd;
  do {
    idx += 1;
    token = tokens[idx];
    if (
      token.type === tokTypes.backQuote
    ) {
      throw new Error('Template strings are not supported');
    } else {
      valueArray.push(typeof token.value !== 'undefined' ? token.value : token.type.label);
    }
    valueEnd = idx;
  } while (tokens[idx + 1].type !== tokTypes.comma && tokens[idx + 1].type !== tokTypes.braceR);
  const value = valueArray.join('');
  return {
    key: keyArray.join(''),
    value,
    startIdx,
    valueStart,
    valueEnd,
    endIdx: tokens[idx + 1].type === tokTypes.comma ? idx + 1 : idx,
  };
}
github karthikv / tradeship / visits / find-style.js View on Github external
function getTrailingToken(context, node, lastItem) {
  switch (node.type) {
    case "ObjectExpression":
    case "ArrayExpression":
    case "CallExpression":
    case "NewExpression":
      return context.getLastToken(node, 1);
    default: {
      const nextToken = context.getTokenAfter(lastItem);

      if (nextToken.type === tokTypes.comma) {
        return nextToken;
      }
      return context.getLastToken(lastItem);
    }
  }
}
github ringcentral / ringcentral-js-widgets / packages / locale-loader / lib / getRawData / index.js View on Github external
token.type === tokTypes.backQuote
    ) {
      throw new Error('Template strings are not supported');
    } else {
      valueArray.push(typeof token.value !== 'undefined' ? token.value : token.type.label);
    }
    valueEnd = idx;
  } while (tokens[idx + 1].type !== tokTypes.comma && tokens[idx + 1].type !== tokTypes.braceR);
  const value = valueArray.join('');
  return {
    key: keyArray.join(''),
    value,
    startIdx,
    valueStart,
    valueEnd,
    endIdx: tokens[idx + 1].type === tokTypes.comma ? idx + 1 : idx,
  };
}