UNPKG

369 BJavaScriptView Raw
1
2import {TokenType as tt} from "../parser/tokenizer/types";
3
4/**
5 * Get all identifier names in the code, in order, including duplicates.
6 */
7export default function getIdentifierNames(code, tokens) {
8 const names = [];
9 for (const token of tokens) {
10 if (token.type === tt.name) {
11 names.push(code.slice(token.start, token.end));
12 }
13 }
14 return names;
15}