ethers.js/src.ts/utils/storage.ts
2022-09-05 16:14:43 -04:00

11 lines
336 B
TypeScript

export function getStore<T, P extends keyof T>(store: T, key: P): T[P] {
return store[key];
}
export function setStore<T, P extends keyof T>(store: T, key: P, value: T[P]): void {
if (Object.isFrozen(store)) {
throw new Error(`frozen object is immuatable; cannot set ${ String(key) }`);
}
store[key] = value;
}