getIdentifierNames.js 472 B

123456789101112131415
  1. "use strict";Object.defineProperty(exports, "__esModule", {value: true});
  2. var _types = require('../parser/tokenizer/types');
  3. /**
  4. * Get all identifier names in the code, in order, including duplicates.
  5. */
  6. function getIdentifierNames(code, tokens) {
  7. const names = [];
  8. for (const token of tokens) {
  9. if (token.type === _types.TokenType.name) {
  10. names.push(code.slice(token.start, token.end));
  11. }
  12. }
  13. return names;
  14. } exports.default = getIdentifierNames;