From c874f28eec621a0fe8c86a5e586ac34b43acca6e Mon Sep 17 00:00:00 2001 From: Elizabeth Hunt Date: Tue, 5 Dec 2023 20:42:06 -0700 Subject: composition of piecewise functions (jesus) --- utils/jsonds.ts | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) (limited to 'utils/jsonds.ts') diff --git a/utils/jsonds.ts b/utils/jsonds.ts index c717232..657c787 100644 --- a/utils/jsonds.ts +++ b/utils/jsonds.ts @@ -29,19 +29,19 @@ export class JSONSet { } } -export class JSONHashMap { - private map: Map; +export class JSONHashMap { + private map: Map; constructor() { - this.map = new Map(); + this.map = new Map(); } - set(key: T, value: T): void { + set(key: T, value: R): void { const keyJson = JSON.stringify(key, Object.keys(key).sort()); this.map.set(keyJson, value); } - get(key: T): T | undefined { + get(key: T): R | undefined { const keyJson = JSON.stringify(key, Object.keys(key).sort()); return this.map.get(keyJson); } @@ -51,6 +51,10 @@ export class JSONHashMap { return this.map.has(keyJson); } + keys(): T[] { + return Array.from(this.map.keys()).map((x) => JSON.parse(x) as T); + } + delete(key: T): boolean { const keyJson = JSON.stringify(key, Object.keys(key).sort()); return this.map.delete(keyJson); -- cgit v1.2.3-70-g09d2