Last active
May 18, 2021 11:28
-
-
Save karol-majewski/c5aeb9c6f2ded29a3bda468572e9a0a9 to your computer and use it in GitHub Desktop.
Create an append-only Map in TypeScript
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
interface Dictionary<K, V> { | |
forEach(callbackfn: (value: V, key: K, map: Dictionary<K, V>) => void, thisArg?: any): void; | |
set(key: K, value: V): this; | |
has<T extends K>(key: T): this is { get(key: T): V } & Dictionary<K, V>; | |
has(key: K): boolean; | |
get(key: K): V | undefined; | |
readonly size: number; | |
} | |
interface DictionaryConstructor { | |
new<K, V>(entries?: readonly (readonly [K, V])[] | null): Dictionary<K, V>; | |
} | |
const Dictionary: DictionaryConstructor = Map; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Usage: