Skip to content

Commit 19cc427

Browse files
committed
Format + new regex
1 parent ddd8c95 commit 19cc427

File tree

1 file changed

+12
-14
lines changed

1 file changed

+12
-14
lines changed

src/compiler/core.ts

+12-14
Original file line numberDiff line numberDiff line change
@@ -74,13 +74,13 @@ namespace ts {
7474
}
7575

7676
// The global Map object. This may not be available, so we must test for it.
77-
declare const Map: { new<T>(): Map<T> } | undefined;
77+
declare const Map: { new <T>(): Map<T> } | undefined;
7878
// Internet Explorer's Map doesn't support iteration, so don't use it.
7979
// tslint:disable-next-line:no-in-operator
8080
const MapCtr = typeof Map !== "undefined" && "entries" in Map.prototype ? Map : shimMap();
8181

8282
// Keep the class inside a function so it doesn't get compiled if it's not used.
83-
function shimMap(): { new<T>(): Map<T> } {
83+
function shimMap(): { new <T>(): Map<T> } {
8484

8585
class MapIterator<T, U extends (string | T | [string, T])> {
8686
private data: MapLike<T>;
@@ -103,7 +103,7 @@ namespace ts {
103103
}
104104
}
105105

106-
return class<T> implements Map<T> {
106+
return class <T> implements Map<T> {
107107
private data = createDictionaryObject<T>();
108108
public size = 0;
109109

@@ -166,8 +166,8 @@ namespace ts {
166166
}
167167

168168
export const enum Comparison {
169-
LessThan = -1,
170-
EqualTo = 0,
169+
LessThan = -1,
170+
EqualTo = 0,
171171
GreaterThan = 1
172172
}
173173

@@ -2417,13 +2417,11 @@ namespace ts {
24172417
* Takes a string like "jquery-min.4.2.3" and returns "jquery"
24182418
*/
24192419
export function removeMinAndVersionNumbers(fileName: string) {
2420-
const match = /((\w|(-(?!min)))+)(\.|-)?.*/.exec(fileName);
2421-
if (match) {
2422-
return match[1];
2423-
}
2424-
else {
2425-
return fileName;
2426-
}
2420+
// Match a "." or "-" followed by a version number or 'min' at the end of the name
2421+
const trailingMinOrVersion = /[.-]((min)|(\d+(\.\d+)*))$/;
2422+
2423+
// The "min" or version may both be present, in either order, so try applying the above twice.
2424+
return fileName.replace(trailingMinOrVersion, "").replace(trailingMinOrVersion, "");
24272425
}
24282426

24292427
export interface ObjectAllocator {
@@ -2627,7 +2625,7 @@ namespace ts {
26272625
return findBestPatternMatch(patterns, _ => _, candidate);
26282626
}
26292627

2630-
export function patternText({prefix, suffix}: Pattern): string {
2628+
export function patternText({ prefix, suffix }: Pattern): string {
26312629
return `${prefix}*${suffix}`;
26322630
}
26332631

@@ -2657,7 +2655,7 @@ namespace ts {
26572655
return matchedValue;
26582656
}
26592657

2660-
function isPatternMatch({prefix, suffix}: Pattern, candidate: string) {
2658+
function isPatternMatch({ prefix, suffix }: Pattern, candidate: string) {
26612659
return candidate.length >= prefix.length + suffix.length &&
26622660
startsWith(candidate, prefix) &&
26632661
endsWith(candidate, suffix);

0 commit comments

Comments
 (0)