-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
51 lines (48 loc) · 852 Bytes
/
index.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
module.exports.get = function(key){
if (localStorage) {
try {
return JSON.parse(localStorage.getItem(key));
} catch (err) {
return null;
}
} else {
return null;
}
};
module.exports.set = function(key, value){
if (localStorage) {
try {
var val = JSON.stringify(value);
localStorage.setItem(key, val);
return val;
} catch (err) {
return null;
}
} else {
return null;
}
};
module.exports.remove = function(key){
if (localStorage) {
try {
localStorage.removeItem(key);
return true;
} catch (err) {
return null;
}
} else {
return null;
}
};
module.exports.clear = function(){
if (localStorage) {
try {
localStorage.clear();
return true;
} catch (err) {
return null;
}
} else {
return null;
}
};