packages/babel-highlight/src/index.js
function getTokenType(match) {
  const [offset, text] = match.slice(-2);
  const token = matchToToken(match);

  if (token.type === "name") {
    if (esutils.keyword.isReservedWordES6(token.value)) {
      return "keyword";
    }

    if (
      JSX_TAG.test(token.value) &&
      (text[offset - 1] === "<" || text.substr(offset - 2, 2) == "</")
    ) {
      return "jsx_tag";
    }

    if (token.value[0] !== token.value[0].toLowerCase()) {
      return "capitalized";
    }
  }

  if (token.type === "punctuator" && BRACKET.test(token.value)) {
    return "bracket";
  }

  if (
    token.type === "invalid" &&
    (token.value === "@" || token.value === "#")
  ) {
    return "punctuator";
  }

  return token.type;
}
function getTokenType(match) {
  const [offset, text] = match.slice(-2);
  const token = matchToToken(match);

  if (token.type === "name") {
    if (esutils.keyword.isReservedWordES6(token.value)) {
      return "keyword";
    }

    if (
      JSX_TAG.test(token.value) &&
      (text[offset - 1] === "<" || text.substr(offset - 2, 2) == "</")
    ) {
      return "jsx_tag";
    }

    if (token.value[0] !== token.value[0].toLowerCase()) {
      return "capitalized";
    }
  }

  if (token.type === "punctuator" && BRACKET.test(token.value)) {
    return "bracket";
  }

  if (
    token.type === "invalid" &&
    (token.value === "@" || token.value === "#")
  ) {
    return "punctuator";
  }

  return token.type;
}
function getTokenType ( match ) { const [ offset , text ] = match . slice ( - 2 ) ; const token = matchToToken ( match ) ; if ( token . type === "name" ) { if ( esutils . keyword . isReservedWordES6 ( token . value ) ) { return "keyword" ; } if ( JSX_TAG . test ( token . value ) && ( text [ offset - 1 ] === "<" || text . substr ( offset - 2 , 2 ) == "</" ) ) { return "jsx_tag" ; } if ( token . value [ 0 ] !== token . value [ 0 ] . toLowerCase ( ) ) { return "capitalized" ; } } if ( token . type === "punctuator" && BRACKET . test ( token . value ) ) { return "bracket" ; } if ( token . type === "invalid" && ( token . value === "@" || token . value === "#" ) ) { return "punctuator" ; } return token . type ; }
Get the type of token, specifying punctuator type.
Get the type of token specifying punctuator type .