-
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathutlis.js
More file actions
28 lines (27 loc) · 757 Bytes
/
utlis.js
File metadata and controls
28 lines (27 loc) · 757 Bytes
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
export default {
uuid(){
var i, random;
var uuid = '';
for (i = 0; i < 32; i++) {
random = Math.random() * 16 | 0;
if (i === 8 || i === 12 || i === 16 || i === 20) {
uuid += '-';
}
uuid += (i === 12 ? 4 : (i === 16 ? (random & 3 | 8) : random)).toString(16);
}
return uuid;
},
pluralize(count, word) {
return count > 0 ? `${word}s` : word;
},
store(namespace, data) {
if (data) {
return localStorage.setItem(namespace, JSON.stringify(data));
}
var store = localStorage.getItem(namespace);
return (store && JSON.parse(store)) || [];
},
destroy(namespace){
localStorage.removeItem(namespace)
}
}