Urara-Blog/node_modules/.pnpm-store/v3/files/1c/4681bd58b6ee96dd88f28abe5f444b9b496269d5fb33da91fc8768085e37e8d42f0a056de77fd61e4f247391ea7e98c81d901b5101bf078280ad9466d97eca
2022-08-14 01:14:53 +08:00

44 lines
1.7 KiB
Text

"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':
// Note: default values not currently supported
return false;
// disregard `bar` in `bar = thing()`
case 'AssignmentExpression':
return parent.right === node;
case 'MemberExpression':
return parent.computed || node === parent.object;
// disregard the `bar` in `{ bar: foo }`
case 'Property':
return node === parent.value;
// disregard the `bar` in `class Foo { bar () {...} }`
case 'MethodDefinition':
return false;
// disregard the `bar` in var bar = asdf
case 'VariableDeclarator':
return parent.id !== node;
// disregard the `bar` in `export { foo as bar }`
case 'ExportSpecifier':
return false;
// disregard the `bar` in `function (bar) {}`
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;