This repository was archived by the owner on Jul 30, 2025. It is now read-only.
File tree Expand file tree Collapse file tree 2 files changed +12
-0
lines changed Expand file tree Collapse file tree 2 files changed +12
-0
lines changed Original file line number Diff line number Diff line change @@ -9,6 +9,7 @@ interface SimpleLocalStorage {
9
9
interface SimpleWindow {
10
10
addEventListener ?: ( ) => void
11
11
localStorage ?: SimpleLocalStorage
12
+ sessionStorage ?: SimpleLocalStorage
12
13
}
13
14
14
15
interface SimpleDocument {
@@ -23,6 +24,7 @@ declare module NodeJS {
23
24
interface Global {
24
25
window : SimpleWindow
25
26
localStorage : SimpleLocalStorage
27
+ sessionStorage : SimpleLocalStorage
26
28
document : SimpleDocument
27
29
}
28
30
}
Original file line number Diff line number Diff line change @@ -173,20 +173,30 @@ export default function() {
173
173
global . window = { }
174
174
try {
175
175
global . localStorage = Store ( )
176
+ global . sessionStorage = Store ( )
176
177
debug ( 'successfully initialized persistent localStorage' )
177
178
} catch ( err ) {
178
179
debug ( 'error initializing persistent localStorage' , err )
179
180
180
181
const _localStorage : Record < string , string > = { }
182
+ const _sessionStorage : Record < string , string > = { }
181
183
global . localStorage = {
182
184
setItem : ( k : string , v : string ) => {
183
185
_localStorage [ k ] = v
184
186
return v
185
187
} ,
186
188
getItem : ( k : string ) => _localStorage [ k ] || null
187
189
}
190
+ global . sessionStorage = {
191
+ setItem : ( k : string , v : string ) => {
192
+ _sessionStorage [ k ] = v
193
+ return v
194
+ } ,
195
+ getItem : ( k : string ) => _sessionStorage [ k ] || null
196
+ }
188
197
} finally {
189
198
global . window . localStorage = localStorage
199
+ global . window . sessionStorage = sessionStorage
190
200
}
191
201
192
202
window . addEventListener = ( ) => true
You can’t perform that action at this time.
0 commit comments