Format + new regex

This commit is contained in:
Ryan Cavanaugh
2017-11-09 12:30:36 -08:00
parent ddd8c95c63
commit 19cc42782b

View File

@@ -74,13 +74,13 @@ namespace ts {
}
// The global Map object. This may not be available, so we must test for it.
declare const Map: { new<T>(): Map<T> } | undefined;
declare const Map: { new <T>(): Map<T> } | undefined;
// Internet Explorer's Map doesn't support iteration, so don't use it.
// tslint:disable-next-line:no-in-operator
const MapCtr = typeof Map !== "undefined" && "entries" in Map.prototype ? Map : shimMap();
// Keep the class inside a function so it doesn't get compiled if it's not used.
function shimMap(): { new<T>(): Map<T> } {
function shimMap(): { new <T>(): Map<T> } {
class MapIterator<T, U extends (string | T | [string, T])> {
private data: MapLike<T>;
@@ -103,7 +103,7 @@ namespace ts {
}
}
return class<T> implements Map<T> {
return class <T> implements Map<T> {
private data = createDictionaryObject<T>();
public size = 0;
@@ -166,8 +166,8 @@ namespace ts {
}
export const enum Comparison {
LessThan = -1,
EqualTo = 0,
LessThan = -1,
EqualTo = 0,
GreaterThan = 1
}
@@ -2417,13 +2417,11 @@ namespace ts {
* Takes a string like "jquery-min.4.2.3" and returns "jquery"
*/
export function removeMinAndVersionNumbers(fileName: string) {
const match = /((\w|(-(?!min)))+)(\.|-)?.*/.exec(fileName);
if (match) {
return match[1];
}
else {
return fileName;
}
// Match a "." or "-" followed by a version number or 'min' at the end of the name
const trailingMinOrVersion = /[.-]((min)|(\d+(\.\d+)*))$/;
// The "min" or version may both be present, in either order, so try applying the above twice.
return fileName.replace(trailingMinOrVersion, "").replace(trailingMinOrVersion, "");
}
export interface ObjectAllocator {
@@ -2627,7 +2625,7 @@ namespace ts {
return findBestPatternMatch(patterns, _ => _, candidate);
}
export function patternText({prefix, suffix}: Pattern): string {
export function patternText({ prefix, suffix }: Pattern): string {
return `${prefix}*${suffix}`;
}
@@ -2657,7 +2655,7 @@ namespace ts {
return matchedValue;
}
function isPatternMatch({prefix, suffix}: Pattern, candidate: string) {
function isPatternMatch({ prefix, suffix }: Pattern, candidate: string) {
return candidate.length >= prefix.length + suffix.length &&
startsWith(candidate, prefix) &&
endsWith(candidate, suffix);