forked from Kieran/snort
fix: sorted map
This commit is contained in:
parent
36b9538aa6
commit
a622c459d7
@ -2,7 +2,7 @@ import { describe, expect, it } from "vitest";
|
|||||||
|
|
||||||
import RBSortedMap from "../../../../tests/RBSortedMap.ts";
|
import RBSortedMap from "../../../../tests/RBSortedMap.ts";
|
||||||
|
|
||||||
import SortedMap from "./SortedMap.tsx";
|
import SortedMap from "./SortedMap.ts";
|
||||||
|
|
||||||
function runTestsForMap(MapConstructor: any, mapName: string) {
|
function runTestsForMap(MapConstructor: any, mapName: string) {
|
||||||
describe(mapName, () => {
|
describe(mapName, () => {
|
||||||
|
@ -10,7 +10,12 @@ export class SortedMap<K, V> {
|
|||||||
|
|
||||||
if (compare) {
|
if (compare) {
|
||||||
if (typeof compare === "string") {
|
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 {
|
} else {
|
||||||
this.compare = compare;
|
this.compare = compare;
|
||||||
}
|
}
|
@ -13,6 +13,7 @@
|
|||||||
"outDir": "dist",
|
"outDir": "dist",
|
||||||
"skipLibCheck": true
|
"skipLibCheck": true
|
||||||
},
|
},
|
||||||
|
"exclude": ["src/**/*.test.ts"],
|
||||||
"include": ["src/**/*.ts", "src/.d.ts"],
|
"include": ["src/**/*.ts", "src/.d.ts"],
|
||||||
"files": ["src/index.ts"]
|
"files": ["src/index.ts"]
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user