MCPcopy Index your code
hub / github.com/ethereum/node-crawler / SortedMap

Function SortedMap

frontend/src/data/SortedMap.ts:13–31  ·  view source on GitHub ↗
(comparator: (a: [K, V], b: [K, V]) => number)

Source from the content-addressed store, hash-verified

11}
12
13export function SortedMap<K, V>(comparator: (a: [K, V], b: [K, V]) => number): ISortedMap<K, V> {
14 const obj = new Map<K, V>();
15 obj[Symbol.iterator] = function* () {
16 yield* [...this.entries()].sort(comparator);
17 };
18 return {
19 size: () => obj.size,
20 clear: () => obj.clear(),
21 delete: (key: K) => obj.delete(key),
22 forEach: (callbackfn: (value: V, key: K, map: Map<K, V>) => void, thisArg?: any) => obj.forEach(callbackfn, thisArg),
23 get: (key: K) => obj.get(key),
24 has: (key: K) => obj.has(key),
25 set: (key: K, value: V) => obj.set(key, value),
26 map: (callbackfn: (value: [K, V], index: number, array: [K, V][]) => any, thisArg?: any) => {
27 return [...obj].map(callbackfn, thisArg)
28 },
29 iterator: obj
30 }
31}

Callers 1

queryDataFunction · 0.90

Calls 6

clearMethod · 0.80
deleteMethod · 0.80
forEachMethod · 0.80
getMethod · 0.80
hasMethod · 0.80
setMethod · 0.80

Tested by

no test coverage detected