New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

typescript-parser

Package Overview
Dependencies
Maintainers
1
Versions
24
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

typescript-parser - npm Package Compare versions

Comparing version 2.3.0 to 2.3.1

6

package.json
{
"name": "typescript-parser",
"version": "2.3.0",
"version": "2.3.1",
"description": "Parser for typescript (and javascript) files, that compiles those files and generates a human understandable AST.",

@@ -27,2 +27,6 @@ "main": "index.js",

],
"release": {
"success": false,
"fail": false
},
"author": "Christoph Bühler <christoph.buehler@bluewin.ch>",

@@ -29,0 +33,0 @@ "license": "MIT",

38

src/TypescriptParser.ts

@@ -154,44 +154,37 @@ import { readFileSync } from 'fs';

*/
private parse(rootResource: Resource, rootNode: Node): void {
let [resource, ...resourceQueue]: Resource[] = Array(rootNode.getChildren().length).fill(rootResource);
let [node, ...nodeQueue]: Node[] = [...rootNode.getChildren()];
while (node) {
switch (node.kind) {
private parse(resource: Resource, node: Node): void {
for (const child of node.getChildren()) {
switch (child.kind) {
case SyntaxKind.ImportDeclaration:
case SyntaxKind.ImportEqualsDeclaration:
parseImport(resource, <ImportDeclaration | ImportEqualsDeclaration>node);
parseImport(resource, <ImportDeclaration | ImportEqualsDeclaration>child);
break;
case SyntaxKind.ExportDeclaration:
case SyntaxKind.ExportAssignment:
parseExport(resource, <ExportAssignment | ExportDeclaration>node);
parseExport(resource, <ExportAssignment | ExportDeclaration>child);
break;
case SyntaxKind.EnumDeclaration:
parseEnum(resource, <EnumDeclaration>node);
parseEnum(resource, <EnumDeclaration>child);
break;
case SyntaxKind.TypeAliasDeclaration:
parseTypeAlias(resource, <TypeAliasDeclaration>node);
parseTypeAlias(resource, <TypeAliasDeclaration>child);
break;
case SyntaxKind.FunctionDeclaration:
parseFunction(resource, <FunctionDeclaration>node);
[resource, ...resourceQueue] = resourceQueue;
[node, ...nodeQueue] = nodeQueue;
parseFunction(resource, <FunctionDeclaration>child);
continue;
case SyntaxKind.VariableStatement:
parseVariable(resource, <VariableStatement>node);
parseVariable(resource, <VariableStatement>child);
break;
case SyntaxKind.InterfaceDeclaration:
parseInterface(resource, <InterfaceDeclaration>node);
parseInterface(resource, <InterfaceDeclaration>child);
break;
case SyntaxKind.ClassDeclaration:
parseClass(resource, <ClassDeclaration>node);
[resource, ...resourceQueue] = resourceQueue;
[node, ...nodeQueue] = nodeQueue;
parseClass(resource, <ClassDeclaration>child);
continue;
case SyntaxKind.Identifier:
parseIdentifier(resource, <Identifier>node);
parseIdentifier(resource, <Identifier>child);
break;
case SyntaxKind.ModuleDeclaration:
const newResource = parseModule(resource, <ModuleDeclaration>node);
[resource, ...resourceQueue] = [...Array(node.getChildren().length).fill(newResource), ...resourceQueue];
[node, ...nodeQueue] = [...node.getChildren(), ...nodeQueue];
const newResource = parseModule(resource, <ModuleDeclaration>child);
this.parse(newResource, child);
continue;

@@ -201,6 +194,5 @@ default:

}
[resource, ...resourceQueue] = [...Array(node.getChildren().length).fill(resource), ...resourceQueue];
[node, ...nodeQueue] = [...node.getChildren(), ...nodeQueue];
this.parse(resource, child);
}
}
}

@@ -67,3 +67,3 @@ import { ScriptKind } from 'typescript';

*/
private parse(rootResource, rootNode);
private parse(resource, node);
}

@@ -120,44 +120,37 @@ "use strict";

*/
parse(rootResource, rootNode) {
let [resource, ...resourceQueue] = Array(rootNode.getChildren().length).fill(rootResource);
let [node, ...nodeQueue] = [...rootNode.getChildren()];
while (node) {
switch (node.kind) {
parse(resource, node) {
for (const child of node.getChildren()) {
switch (child.kind) {
case typescript_1.SyntaxKind.ImportDeclaration:
case typescript_1.SyntaxKind.ImportEqualsDeclaration:
import_parser_1.parseImport(resource, node);
import_parser_1.parseImport(resource, child);
break;
case typescript_1.SyntaxKind.ExportDeclaration:
case typescript_1.SyntaxKind.ExportAssignment:
export_parser_1.parseExport(resource, node);
export_parser_1.parseExport(resource, child);
break;
case typescript_1.SyntaxKind.EnumDeclaration:
enum_parser_1.parseEnum(resource, node);
enum_parser_1.parseEnum(resource, child);
break;
case typescript_1.SyntaxKind.TypeAliasDeclaration:
type_alias_parser_1.parseTypeAlias(resource, node);
type_alias_parser_1.parseTypeAlias(resource, child);
break;
case typescript_1.SyntaxKind.FunctionDeclaration:
function_parser_1.parseFunction(resource, node);
[resource, ...resourceQueue] = resourceQueue;
[node, ...nodeQueue] = nodeQueue;
function_parser_1.parseFunction(resource, child);
continue;
case typescript_1.SyntaxKind.VariableStatement:
variable_parser_1.parseVariable(resource, node);
variable_parser_1.parseVariable(resource, child);
break;
case typescript_1.SyntaxKind.InterfaceDeclaration:
interface_parser_1.parseInterface(resource, node);
interface_parser_1.parseInterface(resource, child);
break;
case typescript_1.SyntaxKind.ClassDeclaration:
class_parser_1.parseClass(resource, node);
[resource, ...resourceQueue] = resourceQueue;
[node, ...nodeQueue] = nodeQueue;
class_parser_1.parseClass(resource, child);
continue;
case typescript_1.SyntaxKind.Identifier:
identifier_parser_1.parseIdentifier(resource, node);
identifier_parser_1.parseIdentifier(resource, child);
break;
case typescript_1.SyntaxKind.ModuleDeclaration:
const newResource = module_parser_1.parseModule(resource, node);
[resource, ...resourceQueue] = [...Array(node.getChildren().length).fill(newResource), ...resourceQueue];
[node, ...nodeQueue] = [...node.getChildren(), ...nodeQueue];
const newResource = module_parser_1.parseModule(resource, child);
this.parse(newResource, child);
continue;

@@ -167,4 +160,3 @@ default:

}
[resource, ...resourceQueue] = [...Array(node.getChildren().length).fill(resource), ...resourceQueue];
[node, ...nodeQueue] = [...node.getChildren(), ...nodeQueue];
this.parse(resource, child);
}

@@ -171,0 +163,0 @@ }

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc