Identifier.js 771 B

1234567891011121314151617181920212223242526272829303132333435
  1. "use strict";
  2. Object.defineProperty(exports, "__esModule", {
  3. value: true
  4. });
  5. exports.default = extractValueFromIdentifier;
  6. var JS_RESERVED = {
  7. Array: Array,
  8. Date: Date,
  9. Infinity: Infinity,
  10. Math: Math,
  11. Number: Number,
  12. Object: Object,
  13. String: String,
  14. undefined: undefined
  15. };
  16. /**
  17. * Extractor function for a Identifier type value node.
  18. * An Identifier is usually a reference to a variable.
  19. * Just return variable name to determine its existence.
  20. *
  21. * @param - value - AST Value object with type `Identifier`
  22. * @returns - The extracted value converted to correct type.
  23. */
  24. function extractValueFromIdentifier(value) {
  25. var name = value.name;
  26. if (Object.hasOwnProperty.call(JS_RESERVED, name)) {
  27. return JS_RESERVED[name];
  28. }
  29. return name;
  30. }