You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
24 lines
630 B
24 lines
630 B
2 years ago
|
// @flow
|
||
|
import getStorage from './getStorage'
|
||
|
|
||
|
export default function createWebStorage(type: string) {
|
||
|
let storage = getStorage(type)
|
||
|
return {
|
||
|
getItem: (key: string): Promise<string> => {
|
||
|
return new Promise((resolve, reject) => {
|
||
|
resolve(storage.getItem(key))
|
||
|
})
|
||
|
},
|
||
|
setItem: (key: string, item: string): Promise<void> => {
|
||
|
return new Promise((resolve, reject) => {
|
||
|
resolve(storage.setItem(key, item))
|
||
|
})
|
||
|
},
|
||
|
removeItem: (key: string): Promise<void> => {
|
||
|
return new Promise((resolve, reject) => {
|
||
|
resolve(storage.removeItem(key))
|
||
|
})
|
||
|
},
|
||
|
}
|
||
|
}
|