-
Notifications
You must be signed in to change notification settings - Fork 0
/
patchIdbKv.js
29 lines (28 loc) · 941 Bytes
/
patchIdbKv.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
const patchIdbKv = (IdbKvStore) => {
IdbKvStore.prototype.get = function (key) {
return new Promise((resolve,reject) => {
this.transaction('readonly').get(key,(err,value) => {
if(err) reject(err);
else resolve(value);
});
});
}
IdbKvStore.prototype.set = function (key,value) {
return new Promise((resolve,reject) => {
this.transaction('readwrite').set(key,value,(err,value) => {
if(err) reject(err);
else resolve(value);
});
});
}
IdbKvStore.prototype.remove = function (key) {
return new Promise((resolve,reject) => {
this.transaction('readwrite').remove(key,(err,value) => {
if(err) reject(err);
else resolve(value);
});
});
}
return IdbKvStore;
}
export { patchIdbKv, patchIdbKv as default };