Quick tweaks

This commit is contained in:
Jeremy
2023-02-21 19:58:18 -05:00
parent 8f667c415f
commit a583c435ab
2 changed files with 13 additions and 10 deletions
+11
View File
@@ -44,3 +44,14 @@ export function remove<U, V extends U>(arr: U[], v: V) {
return arr.filter(item => item !== v) as Exclude<U, V extends null | undefined ? V : never>[];
}
// https://www.typescriptlang.org/play?#code/KYDwDg9gTgLgBAMwK4DsDGMCWEVysAWwgDdgAeAVQBo4A1OUGYFAEwGc4KA+ACgEMoUAFycA2gF0axEbQCUcAN4AoOKrzAYSKLgFQAdAkwAbJlB6YmBOAF4ucC4TgBCa9bjF5fDgFEQaI0gs5NR0DCBMrBwoSEZGcAA+cKhBhijALHAA-KEiaaRQXBIA3EoAvkpKQf4CwHBoOGzwuiI8jVCYKADmCXDRsbLFFfUojXAgNupEpPyCNH1GsiUA9EtqcAB6mUMN8ACeE-hTwDNQNABECBAQZ4tKK2ubFUA
// For Array.prototype.sort
export function basic_comparator<T>(a: T, b: T) {
if (a < b) {
return -1;
} else if (a > b) {
return 1;
} else {
return 0;
}
}
+2 -10
View File
@@ -41,7 +41,7 @@ import {logger} from './logger';
import {ClientOptionsHandler, OptionHandlerArguments} from './options-handler';
import {CompilerProps} from './properties';
import {PropertyGetter} from './properties.interfaces';
import {remove} from './common-utils';
import {basic_comparator, remove} from './common-utils';
const sleep = promisify(setTimeout);
@@ -456,15 +456,7 @@ export class CompilerFinder {
const result = this.ensureDistinct(compilers);
return {
foundClash: result.foundClash,
compilers: result.compilers.sort((a, b) => {
if (a.name < b.name) {
return -1;
} else if (a.name > b.name) {
return 1;
} else {
return 0;
}
}),
compilers: result.compilers.sort((a, b) => basic_comparator(a.name, b.name)),
};
}