11import { storageSettings } from "../index.js" ;
2- import { StorageKeys , type SessionManager } from "../types.js" ;
2+ import { SessionBase , StorageKeys , type SessionManager } from "../types.js" ;
33import { splitString } from "../utils.js" ;
44
55/**
66 * Provides a localStorage based session manager implementation for the browser.
77 * @class LocalStorage
88 */
9- export class LocalStorage < V = StorageKeys > implements SessionManager < V > {
9+ export class LocalStorage < V extends string = StorageKeys > extends SessionBase < V > implements SessionManager < V > {
1010 constructor ( ) {
11+ super ( ) ;
1112 console . warn ( "LocalStorage store should not be used in production" ) ;
1213 }
1314
14- setItems : Set < V | StorageKeys > = new Set < V > ( ) ;
15+ private internalItems : Set < V | StorageKeys > = new Set < V > ( ) ;
1516
1617 /**
1718 * Clears all items from session store.
1819 * @returns {void }
1920 */
2021 async destroySession ( ) : Promise < void > {
21- this . setItems . forEach ( ( key ) => {
22+ this . internalItems . forEach ( ( key ) => {
2223 this . removeSessionItem ( key ) ;
2324 } ) ;
2425 }
@@ -35,7 +36,7 @@ export class LocalStorage<V = StorageKeys> implements SessionManager<V> {
3536 ) : Promise < void > {
3637 // clear items first
3738 await this . removeSessionItem ( itemKey ) ;
38- this . setItems . add ( itemKey ) ;
39+ this . internalItems . add ( itemKey ) ;
3940
4041 if ( typeof itemValue === "string" ) {
4142 splitString ( itemValue , storageSettings . maxLength ) . forEach (
@@ -97,6 +98,6 @@ export class LocalStorage<V = StorageKeys> implements SessionManager<V> {
9798
9899 index ++ ;
99100 }
100- this . setItems . delete ( itemKey ) ;
101+ this . internalItems . delete ( itemKey ) ;
101102 }
102103}
0 commit comments