1 line
2.7 KiB
JSON
1 line
2.7 KiB
JSON
{"ast":null,"code":"\"use strict\";\n\nObject.defineProperty(exports, \"__esModule\", {\n value: true\n});\nexports.default = getBindingIdentifiers;\n\nvar _generated = require(\"../validators/generated\");\n\nfunction getBindingIdentifiers(node, duplicates, outerOnly) {\n var search = [].concat(node);\n var ids = Object.create(null);\n\n while (search.length) {\n var id = search.shift();\n if (!id) continue;\n var keys = getBindingIdentifiers.keys[id.type];\n\n if ((0, _generated.isIdentifier)(id)) {\n if (duplicates) {\n var _ids = ids[id.name] = ids[id.name] || [];\n\n _ids.push(id);\n } else {\n ids[id.name] = id;\n }\n\n continue;\n }\n\n if ((0, _generated.isExportDeclaration)(id)) {\n if ((0, _generated.isDeclaration)(id.declaration)) {\n search.push(id.declaration);\n }\n\n continue;\n }\n\n if (outerOnly) {\n if ((0, _generated.isFunctionDeclaration)(id)) {\n search.push(id.id);\n continue;\n }\n\n if ((0, _generated.isFunctionExpression)(id)) {\n continue;\n }\n }\n\n if (keys) {\n for (var i = 0; i < keys.length; i++) {\n var key = keys[i];\n\n if (id[key]) {\n search = search.concat(id[key]);\n }\n }\n }\n }\n\n return ids;\n}\n\ngetBindingIdentifiers.keys = {\n DeclareClass: [\"id\"],\n DeclareFunction: [\"id\"],\n DeclareModule: [\"id\"],\n DeclareVariable: [\"id\"],\n DeclareInterface: [\"id\"],\n DeclareTypeAlias: [\"id\"],\n DeclareOpaqueType: [\"id\"],\n InterfaceDeclaration: [\"id\"],\n TypeAlias: [\"id\"],\n OpaqueType: [\"id\"],\n CatchClause: [\"param\"],\n LabeledStatement: [\"label\"],\n UnaryExpression: [\"argument\"],\n AssignmentExpression: [\"left\"],\n ImportSpecifier: [\"local\"],\n ImportNamespaceSpecifier: [\"local\"],\n ImportDefaultSpecifier: [\"local\"],\n ImportDeclaration: [\"specifiers\"],\n ExportSpecifier: [\"exported\"],\n ExportNamespaceSpecifier: [\"exported\"],\n ExportDefaultSpecifier: [\"exported\"],\n FunctionDeclaration: [\"id\", \"params\"],\n FunctionExpression: [\"id\", \"params\"],\n ArrowFunctionExpression: [\"params\"],\n ObjectMethod: [\"params\"],\n ClassMethod: [\"params\"],\n ForInStatement: [\"left\"],\n ForOfStatement: [\"left\"],\n ClassDeclaration: [\"id\"],\n ClassExpression: [\"id\"],\n RestElement: [\"argument\"],\n UpdateExpression: [\"argument\"],\n ObjectProperty: [\"value\"],\n AssignmentPattern: [\"left\"],\n ArrayPattern: [\"elements\"],\n ObjectPattern: [\"properties\"],\n VariableDeclaration: [\"declarations\"],\n VariableDeclarator: [\"id\"]\n};","map":null,"metadata":{},"sourceType":"script"} |