1
0
forked from Kieran/snort

fix: sorted map

This commit is contained in:
Kieran 2024-01-04 16:31:04 +00:00
parent 36b9538aa6
commit a622c459d7
Signed by: Kieran
GPG Key ID: DE71CEB3925BE941
3 changed files with 8 additions and 2 deletions

View File

@ -2,7 +2,7 @@ import { describe, expect, it } from "vitest";
import RBSortedMap from "../../../../tests/RBSortedMap.ts";
import SortedMap from "./SortedMap.tsx";
import SortedMap from "./SortedMap.ts";
function runTestsForMap(MapConstructor: any, mapName: string) {
describe(mapName, () => {

View File

@ -10,7 +10,12 @@ export class SortedMap<K, V> {
if (compare) {
if (typeof compare === "string") {
this.compare = (a, b) => (a[1][compare] > b[1][compare] ? 1 : a[1][compare] < b[1][compare] ? -1 : 0);
this.compare = (a, b) =>
(a[1] as any)[compare] > (b[1] as any)[compare]
? 1
: (a[1] as any)[compare] < (a[1] as any)[compare]
? -1
: 0;
} else {
this.compare = compare;
}

View File

@ -13,6 +13,7 @@
"outDir": "dist",
"skipLibCheck": true
},
"exclude": ["src/**/*.test.ts"],
"include": ["src/**/*.ts", "src/.d.ts"],
"files": ["src/index.ts"]
}