add from and to arguments

This commit is contained in:
Aiden McClelland
2022-07-18 11:57:02 -06:00
parent 028ade0b59
commit 47cf6de393
2 changed files with 41 additions and 33 deletions

View File

@@ -1,3 +1,5 @@
import { matches } from "../dependencies.ts";
const starSub = /((\d+\.)*\d+)\.\*/;
function incrementLastNumber(list: number[]) {
@@ -123,15 +125,22 @@ export class EmVer {
public lessThan(other: EmVer): boolean {
return !this.greaterThanOrEqual(other);
}
public compare(other: EmVer): number {
public compare(other: EmVer) {
if (this.equals(other)) {
return 0;
return "equal" as const;
} else if (this.greaterThan(other)) {
return 1;
return "greater" as const;
} else {
return -1;
return "less" as const;
}
}
public compareForSort(other: EmVer) {
return matches.matches(this.compare(other))
.when("equal", () => 0 as const)
.when("greater", () => 1 as const)
.when("less", () => -1 as const)
.unwrap();
}
}
/**