From 5c78a37ae0a0c9310fd2b06cfcb4959a64154aed Mon Sep 17 00:00:00 2001 From: Kim Biesbjerg Date: Fri, 23 Dec 2016 05:45:06 +0100 Subject: [PATCH] Add support for node 4.3.2+ --- src/parsers/abstract-template.parser.ts | 5 +++-- src/parsers/pipe.parser.ts | 3 +-- src/parsers/service.parser.ts | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/parsers/abstract-template.parser.ts b/src/parsers/abstract-template.parser.ts index e50d385..c6ac050 100644 --- a/src/parsers/abstract-template.parser.ts +++ b/src/parsers/abstract-template.parser.ts @@ -5,14 +5,15 @@ export abstract class AbstractTemplateParser { * makes the assumption that it is an Angular Component */ protected _isAngularComponent(path: string): boolean { - return new RegExp(/\.ts|js$/, 'i').test(path); + return (/\.ts|js$/i).test(path); } /** * Extracts inline template from components */ protected _extractInlineTemplate(contents: string): string { - const match = new RegExp(/template\s*:\s*(["'`])([^\1]*?)\1/).exec(contents); + const regExp: RegExp = /template\s*:\s*(["'`])([^\1]*?)\1/; + const match = regExp.exec(contents); if (match !== null) { return match[2]; } diff --git a/src/parsers/pipe.parser.ts b/src/parsers/pipe.parser.ts index a00d0ad..12e2f9e 100644 --- a/src/parsers/pipe.parser.ts +++ b/src/parsers/pipe.parser.ts @@ -15,8 +15,7 @@ export class PipeParser extends AbstractTemplateParser implements ParserInterfac protected _parseTemplate(template: string): TranslationCollection { let collection: TranslationCollection = new TranslationCollection(); - const regExp = new RegExp(/(['"`])([^\1\r\n]*?)\1\s*\|\s*translate/, 'g'); - + const regExp: RegExp = /(['"`])([^\1\r\n]*?)\1\s*\|\s*translate/g; let matches: RegExpExecArray; while (matches = regExp.exec(template)) { collection = collection.add(matches[2]); diff --git a/src/parsers/service.parser.ts b/src/parsers/service.parser.ts index ec53d35..a7bf654 100644 --- a/src/parsers/service.parser.ts +++ b/src/parsers/service.parser.ts @@ -11,7 +11,7 @@ export class ServiceParser implements ParserInterface { return collection; } - const methodRegExp: RegExp = new RegExp(/(?:get|instant)\s*\(\s*(\[?\s*(['"`])([^\1\r\n]*)\2\s*\]?)/); + const methodRegExp: RegExp = /(?:get|instant)\s*\(\s*(\[?\s*(['"`])([^\1\r\n]*)\2\s*\]?)/; const regExp: RegExp = new RegExp(`${translateServiceVar}\.${methodRegExp.source}`, 'g'); let matches: RegExpExecArray;