From 6bc5d4d083cff4a484c56ff0ea85dbb98e11c935 Mon Sep 17 00:00:00 2001 From: Sriram Hariharan Date: Sat, 13 Apr 2024 02:26:22 -0500 Subject: [PATCH] updated key to store map --- package.json | 2 +- src/storage/debugStore.ts | 14 +++++++++++--- 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/package.json b/package.json index b9d91f7..2396843 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "chrome-extension-toolkit", - "version": "0.0.61", + "version": "0.0.62", "description": "A template for creating npm packages using TypeScript and VSCode", "main": "dist/index.js", "types": "dist/index.d.ts", diff --git a/src/storage/debugStore.ts b/src/storage/debugStore.ts index 55fc4e7..7273e1e 100644 --- a/src/storage/debugStore.ts +++ b/src/storage/debugStore.ts @@ -1,6 +1,9 @@ import { Store } from './createStore'; -export const KEY_TO_STORE_MAP = new Map(); +/** + * A global map of the storage keys to the name of the store that they are associated with + */ +export const KEYS_TO_STORE_MAP = new Map(); /** * a helper function to debug the store in the console. Will only do anything when NODE_ENV is set to "development" @@ -10,8 +13,13 @@ export function debugStore(stores: { [name: string]: Store }) { if (process.env.NODE_ENV === 'development') { const names = Object.keys(stores); for (const name of names) { - globalThis[name] = stores[name]; - KEY_TO_STORE_MAP.set(name, stores[name]); + const store = stores[name]; + globalThis[name] = store; + + const keys = store.keys(); + for (const key of keys) { + KEYS_TO_STORE_MAP.set(key, name); + } } } }