Init
This commit is contained in:
+21
@@ -0,0 +1,21 @@
|
||||
import { SupportedStorage } from './types'
|
||||
|
||||
/**
|
||||
* Returns a localStorage-like object that stores the key-value pairs in
|
||||
* memory.
|
||||
*/
|
||||
export function memoryLocalStorageAdapter(store: { [key: string]: string } = {}): SupportedStorage {
|
||||
return {
|
||||
getItem: (key) => {
|
||||
return store[key] || null
|
||||
},
|
||||
|
||||
setItem: (key, value) => {
|
||||
store[key] = value
|
||||
},
|
||||
|
||||
removeItem: (key) => {
|
||||
delete store[key]
|
||||
},
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user