From e0a7627f12844d0a2c4827bf903881c595c7134b Mon Sep 17 00:00:00 2001 From: Basarat Syed Date: Mon, 3 Aug 2015 11:28:47 +1000 Subject: [PATCH] CR feedback --- src/compiler/scanner.ts | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/src/compiler/scanner.ts b/src/compiler/scanner.ts index 01efc96a86f..379177a9b9c 100644 --- a/src/compiler/scanner.ts +++ b/src/compiler/scanner.ts @@ -538,7 +538,7 @@ namespace ts { return pos; } - let shebangTriviaRegex = /^#!.*/; + const shebangTriviaRegex = /^#!.*/; function isShebangTrivia(text: string, pos: number) { // Shebangs check must only be done at the start of the file @@ -644,12 +644,9 @@ namespace ts { /** Optionally, get the shebang */ export function getShebang(text: string): string { - if (!shebangTriviaRegex.test(text)) { - return undefined; - } - else { - return shebangTriviaRegex.exec(text)[0]; - } + return shebangTriviaRegex.test(text) + ? shebangTriviaRegex.exec(text)[0] + : undefined; } export function isIdentifierStart(ch: number, languageVersion: ScriptTarget): boolean { @@ -1123,7 +1120,7 @@ namespace ts { let ch = text.charCodeAt(pos); // Special handling for shebang - if (ch == CharacterCodes.hash && pos === 0 && isShebangTrivia(text, pos)) { + if (ch === CharacterCodes.hash && pos === 0 && isShebangTrivia(text, pos)) { pos = scanShebangTrivia(text ,pos); if (skipTrivia) { continue;