Skip to content

Commit

Permalink
updated key to store map
Browse files Browse the repository at this point in the history
  • Loading branch information
sghsri committed Apr 13, 2024
1 parent 47e78d1 commit 6bc5d4d
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 4 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -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",
Expand Down
14 changes: 11 additions & 3 deletions src/storage/debugStore.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
import { Store } from './createStore';

export const KEY_TO_STORE_MAP = new Map<string, Store>();
/**
* 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<string, string>();

/**
* a helper function to debug the store in the console. Will only do anything when NODE_ENV is set to "development"
Expand All @@ -10,8 +13,13 @@ export function debugStore(stores: { [name: string]: Store<any> }) {
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);
}
}
}
}

1 comment on commit 6bc5d4d

@github-actions
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Lines Statements Branches Functions
Coverage: 9%
9% (27/300) 14.86% (11/74) 9.72% (7/72)

Please sign in to comment.