"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.isLoop = exports.isVarLoop = exports.isIdentifierRead = void 0;
function isIdentifierRead(node, parent) {
switch (parent.type) {
case 'ObjectPattern':
case 'ArrayPattern':
return false;
case 'AssignmentExpression':
return parent.right === node;
case 'MemberExpression':
return parent.computed || node === parent.object;
case 'Property':
return node === parent.value;
case 'MethodDefinition':
return false;
case 'VariableDeclarator':
return parent.id !== node;
case 'ExportSpecifier':
return false;
case 'FunctionExpression':
case 'FunctionDeclaration':
case 'ArrowFunctionExpression':
return false;
default:
return true;
}
}
exports.isIdentifierRead = isIdentifierRead;
function isVarLoop(node) {
return (node.type === 'ForStatement' ||
node.type === 'ForInStatement' ||
node.type === 'ForOfStatement');
}
exports.isVarLoop = isVarLoop;
function isLoop(node) {
return (node.type === 'ForStatement' ||
node.type === 'ForInStatement' ||
node.type === 'ForOfStatement' ||
node.type === 'WhileStatement' ||
node.type === 'DoWhileStatement');
}
exports.isLoop = isLoop;