Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
function Binary(node, parent) {
if (t.isCallExpression(parent) || (t.isIndexExpression(parent) && parent.identifier === node)) {
return false;
}
if (t.isUnaryExpression(parent)) return true;
if (t.isBinary(parent)) {
const parentOp = parent.operator;
// Unary was tested above
const parentPos = PRECEDENCE[parentOp];
let nodeOp = node.operator;
// Prepend 'U' to differ unary operators
if (t.isUnaryExpression(node)) nodeOp = `U${nodeOp}`;
const nodePos = PRECEDENCE[nodeOp];
if (
(parentPos === nodePos &&
function Literal(node, parent) {
return (t.isIndexExpression(parent) || t.isMemberExpression(parent)) && parent.base === node;
}