-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathlocal-storage.js
executable file
·51 lines (45 loc) · 1.09 KB
/
local-storage.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
ns.storage = (function(ls, window, document) {
var isSupported = ls.supported(), all = {};
function getAll() {
if (localStorage && isSupported) {
var i, hasOwn = Object.prototype.hasOwnProperty;
for (i in localStorage) {
if (hasOwn.call(localStorage, i)) {
if (!i.match(/(-cacheexpiration)/)) {
var name = i.replace('lscache-', '');
all[name] = ls.get(name);
}
}
}
}
return all;
};
function deleteAll() {
if (localStorage && isSupported) {
window.localStorage.clear();
return getAll();
}
return undefined;
};
function init() {
if (localStorage && isSupported) {
getAll();
}
return this;
};
return {
enableWarnings: ls.enableWarnings,
flush: ls.flush,
flushExpired: ls.flushExpired,
get: ls.get,
remove: ls.remove,
resetBucket: ls.resetBucket,
set: ls.set,
setBucket: ls.setBucket,
supported: isSupported,
init: init,
getAll: getAll,
deleteAll: deleteAll,
all: all
};
})(lscache, window, window.document).init();