-
Notifications
You must be signed in to change notification settings - Fork 1.3k
/
oldFF-globalStorage.js
42 lines (34 loc) · 749 Bytes
/
oldFF-globalStorage.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
// oldFF-globalStorage provides storage for Firefox
// versions 6 and 7, where no localStorage, etc
// is available.
var util = require('../src/util')
var Global = util.Global
module.exports = {
name: 'oldFF-globalStorage',
read: read,
write: write,
each: each,
remove: remove,
clearAll: clearAll,
}
var globalStorage = Global.globalStorage
function read(key) {
return globalStorage[key]
}
function write(key, data) {
globalStorage[key] = data
}
function each(fn) {
for (var i = globalStorage.length - 1; i >= 0; i--) {
var key = globalStorage.key(i)
fn(globalStorage[key], key)
}
}
function remove(key) {
return globalStorage.removeItem(key)
}
function clearAll() {
each(function(key, _) {
delete globalStorage[key]
})
}