Skip to content

Instantly share code, notes, and snippets.

View WouterGritter's full-sized avatar

Wouter Gritter WouterGritter

View GitHub Profile
@WouterGritter
WouterGritter / regexMap.ts
Created May 31, 2024 12:43
TypeScript RegexMap implementation (use regexes within the get/has/delete methods)
export class RegexMap<T> implements Map<string, T> {
private readonly backend: Map<string, T>;
constructor(entries?: readonly (readonly [string, T])[] | null) {
this.backend = new Map<string, T>(entries);
}
toJSON(): { [key: string]: T; } {
const result: { [key: string]: T; } = {};