Debian Codegraph @

packages/babel-types/src/validators/buildMatchMemberExpression.ts

raw
1 import matchesPattern from "./matchesPattern";
2 import type * as t from "..";
3
4 /**
5 * Build a function that when called will return whether or not the
6 * input `node` `MemberExpression` matches the input `match`.
7 *
8 * For example, given the match `React.createClass` it would match the
9 * parsed nodes of `React.createClass` and `React["createClass"]`.
10 */
11 export default function buildMatchMemberExpression(
12 match: string,
13 allowPartial?: boolean,
14 ) {
15 const parts = match.split(".");
16
17 return (member: t.Node) => matchesPattern(member, parts, allowPartial);
18 }