UNPKG

astx

Version:

super powerful structural search and replace for JavaScript and TypeScript to automate your refactoring

25 lines (20 loc) 797 B
"use strict"; var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault"); Object.defineProperty(exports, "__esModule", { value: true }); exports["default"] = matchJSXText; var _ = require("."); var _normalizeJSXTextValue = _interopRequireDefault(require("../util/normalizeJSXTextValue")); function matchJSXText(path, compileOptions) { var pattern = path.value; var normalizedValue = (0, _normalizeJSXTextValue["default"])(pattern.value); var n = compileOptions.backend.t.namedTypes; return (0, _.convertPredicateMatcher)(path, { match: function match(path) { var node = path.value; return n.JSXText.check(node) && normalizedValue === (0, _normalizeJSXTextValue["default"])(node.value); }, nodeType: 'JSXText' }, compileOptions); }