AssignmentExpression.js 709 B

12345678910111213141516171819
  1. 'use strict';
  2. Object.defineProperty(exports, "__esModule", {
  3. value: true
  4. });
  5. exports.default = extractValueFromAssignmentExpression;
  6. /**
  7. * Extractor function for a AssignmentExpression type value node.
  8. * An assignment expression looks like `x = y` or `x += y` in expression position.
  9. * This will return the assignment as the value.
  10. *
  11. * @param - value - AST Value object with type `AssignmentExpression`
  12. * @returns - The extracted value converted to correct type.
  13. */
  14. function extractValueFromAssignmentExpression(value) {
  15. // eslint-disable-next-line global-require
  16. var getValue = require('./index.js').default;
  17. return getValue(value.left) + ' ' + value.operator + ' ' + getValue(value.right);
  18. }