-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathvue-localforage.js
72 lines (56 loc) · 1.6 KB
/
vue-localforage.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
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
/*!
* vue-localforage v0.2.4
* shidianxia@gmail.com
* Released under the MIT License.
*/
'use strict'
var localForage = require('localforage')
function VueLocalForage (Vue) {
Vue.prototype.$getItem = function (key, callback) {
return localForage.getItem(key, callback)
}
Vue.prototype.$setItem = function (key, value, callback) {
return localForage.setItem(key, value, callback)
}
Vue.prototype.$removeItem = function (key, callback) {
return localForage.removeItem(key, callback)
}
Vue.prototype.$clearStorage = function () {
localForage.clear()
}
Vue.prototype.$lengthOfStorage = function (callback) {
return localForage.length(callback)
}
Vue.prototype.$keyInStorage = function (keyIndex, callback) {
return localForage.key(keyIndex, callback)
}
Vue.prototype.$keysInStorage = function (callback) {
return localForage.keys(callback)
}
Vue.prototype.$iterateStorage = function (iteratorCallback, callback) {
return localForage.iterate(iteratorCallback, callback)
}
Vue.prototype.$setStorageDriver = function (driverName) {
localForage.setDriver(driverName)
}
Vue.prototype.$storageConfig = function (options) {
localForage.config(options)
}
var functions = [
'$getItem',
'$setItem',
'$removeItem',
'$clearStorage',
'$lengthOfStorage',
'$keyInStorage',
'$iterateStorage',
'$setStorageDriver',
'$storageConfig'
]
Vue.localForage = {}
functions.forEach(function (name) {
Vue.localForage[name] = Vue.prototype[name]
})
}
VueLocalForage.version = '0.2.4'
module.exports = VueLocalForage