Skip to content

Commit dfacb59

Browse files
committed
fix: 🐛 Fixed scoped behaviour in the MemoryStorage
1 parent 67d2633 commit dfacb59

File tree

1 file changed

+10
-4
lines changed

1 file changed

+10
-4
lines changed

src/storage/memory.ts

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -38,12 +38,18 @@ export class MemoryStorage extends Storage {
3838

3939
// Validate MemoryStorageOptions
4040

41-
this.db = new Map<string, unknown>(options?.entries);
42-
4341
if (options.scope) {
4442
this.scopeIdsKey = `memory_storage_scope_${options.scope}_ids`;
4543
}
4644

45+
this.db = new Map<string, unknown>(options?.entries);
46+
47+
if (options.entries) {
48+
options.entries.forEach((e) => {
49+
this.addScopeId(e[0]);
50+
});
51+
}
52+
4753
logger.trace('Memory storage initialized');
4854
}
4955

@@ -86,7 +92,7 @@ export class MemoryStorage extends Storage {
8692
* @returns
8793
* @memberof MemoryStorage
8894
*/
89-
private addScopeId(id: string) {
95+
protected addScopeId(id: string) {
9096
try {
9197
if (!this.scopeIdsKey) {
9298
return;
@@ -220,7 +226,7 @@ export class MemoryStorage extends Storage {
220226
}
221227

222228
// Storage configuration
223-
export const createInitializer: StorageInitializerFunction =
229+
export const createInitializer: StorageInitializerFunction<MemoryStorage> =
224230
(options?: MemoryStorageOptions) =>
225231
// eslint-disable-next-line @typescript-eslint/require-await
226232
async (): Promise<MemoryStorage> => {

0 commit comments

Comments
 (0)