diff --git a/package.json b/package.json index 624c0ad..fc7c91d 100644 --- a/package.json +++ b/package.json @@ -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", diff --git a/src/TypescriptParser.ts b/src/TypescriptParser.ts index 1380470..93cf153 100644 --- a/src/TypescriptParser.ts +++ b/src/TypescriptParser.ts @@ -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. * @@ -92,6 +106,21 @@ export class TypescriptParser { public async parseFiles( filePathes: string[], rootPath: string): Promise { + 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;