Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "typescript-parser",
"version": "0.0.0-development",
"version": "2.6.2",
"description": "Parser for typescript (and javascript) files, that compiles those files and generates a human understandable AST.",
"main": "index.js",
"typings": "index.d.ts",
Expand Down
29 changes: 29 additions & 0 deletions src/TypescriptParser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,20 @@ export class TypescriptParser {
return parse[0];
}

/**
* Parses a single file into a parsed file synchronously.
*
* @param {string} filePath
* @param {string} rootPath
* @returns {File}
*
* @memberof TsResourceParser
*/
public parseFileSync(filePath: string, rootPath: string): File {
const parse = this.parseFilesSync([filePath], rootPath);
return parse[0];
}

/**
* Parses multiple files into parsed files.
*
Expand All @@ -92,6 +106,21 @@ export class TypescriptParser {
public async parseFiles(
filePathes: string[],
rootPath: string): Promise<File[]> {
return this.parseFilesSync(filePathes, rootPath);
}

/**
* Parses multiple files into parsed files Synchronously.
*
* @param {string[]} filePathes
* @param {string} rootPath
* @returns {File[]}
*
* @memberof TsResourceParser
*/
public parseFilesSync(
filePathes: string[],
rootPath: string): File[] {
return filePathes
.map((o) => {
let scriptKind: ScriptKind = ScriptKind.Unknown;
Expand Down