MCPcopy Create free account
hub / github.com/babel/babel / BinaryExpression

Function BinaryExpression

packages/babel-plugin-transform-instanceof/src/index.ts:11–29  ·  view source on GitHub ↗
(path)

Source from the content-addressed store, hash-verified

9
10 visitor: {
11 BinaryExpression(path) {
12 const { node } = path;
13 if (node.operator === "instanceof") {
14 const helper = this.addHelper("instanceof");
15 const isUnderHelper = path.findParent(path => {
16 return (
17 (path.isVariableDeclarator() && path.node.id === helper) ||
18 (path.isFunctionDeclaration() &&
19 path.node.id?.name === helper.name)
20 );
21 });
22
23 if (isUnderHelper) {
24 return;
25 } else {
26 path.replaceWith(t.callExpression(helper, [node.left, node.right]));
27 }
28 }
29 },
30 },
31 };
32});

Callers

nothing calls this directly

Calls 3

isVariableDeclaratorMethod · 0.80
isFunctionDeclarationMethod · 0.80
addHelperMethod · 0.65

Tested by

no test coverage detected