forked from webpack-contrib/webpack-bundle-analyzer
/
utils.js
43 lines (35 loc) · 819 Bytes
/
utils.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
export function isChunkParsed(chunk) {
return (typeof chunk.parsedSize === 'number');
}
export function walkModules(modules, cb) {
for (const module of modules) {
if (cb(module) === false) return false;
if (module.groups) {
if (walkModules(module.groups, cb) === false) {
return false;
}
}
}
}
export function elementIsOutside(elem, container) {
return !(elem === container || container.contains(elem));
}
export const localStorage = {
getItem(k) {
try {
return window.localStorage.getItem(k);
} catch (x) {
return null;
}
},
setItem(k, v) {
try {
window.localStorage.setItem(k, v);
} catch (x) { /* ignored */ }
},
removeItem(k) {
try {
window.localStorage.removeItem(k);
} catch (x) { /* ignored */ }
}
};