File tree Expand file tree Collapse file tree 1 file changed +10
-11
lines changed Expand file tree Collapse file tree 1 file changed +10
-11
lines changed Original file line number Diff line number Diff line change
1
+ /* eslint-disable no-undef */
1
2
export function isLocalStorageAvailable ( ) : boolean {
3
+ var mod = '__SPLITSOFTWARE__' ;
2
4
try {
3
- // eslint-disable-next-line no-undef
4
- return isValidStorageWrapper ( localStorage ) ;
5
+ localStorage . setItem ( mod , mod ) ;
6
+ localStorage . removeItem ( mod ) ;
7
+ return true ;
5
8
} catch ( e ) {
6
9
return false ;
7
10
}
8
11
}
9
12
10
13
export function isValidStorageWrapper ( wrapper : any ) : boolean {
11
- var mod = '__SPLITSOFTWARE__' ;
12
- try {
13
- wrapper . setItem ( mod , mod ) ;
14
- wrapper . getItem ( mod ) ;
15
- wrapper . removeItem ( mod ) ;
16
- return true ;
17
- } catch ( e ) {
18
- return false ;
19
- }
14
+ return wrapper !== null &&
15
+ typeof wrapper === 'object' &&
16
+ typeof wrapper . setItem === 'function' &&
17
+ typeof wrapper . getItem === 'function' &&
18
+ typeof wrapper . removeItem === 'function' ;
20
19
}
You can’t perform that action at this time.
0 commit comments