-
Notifications
You must be signed in to change notification settings - Fork 0
/
utils.js
32 lines (29 loc) · 923 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
/*
taken from https://github.com/Tudmotu/gnome-shell-extension-clipboard-indicator
*/
// Print objects... why no dev tools
function prettyPrint (name, obj, recurse, _indent) {
let prefix = '';
let indent = typeof _indent === 'number' ? _indent : 0;
for (let i = 0; i < indent; i++) {
prefix += ' ';
}
recurse = typeof recurse === 'boolean' ? recurse : true;
if (typeof name !== 'string') {
obj = arguments[0];
recurse = arguments[1];
_indent = arguments[2];
name = obj.toString();
}
log(prefix + '--------------');
log(prefix + name);
log(prefix + '--------------');
for (let k in obj) {
if (typeof obj[k] === 'object' && recurse) {
prettyPrint(name + '::' + k, obj[k], true, indent + 1);
}
else {
log(prefix + k, typeof obj[k] === 'function' ? '[Func]' : obj[k]);
}
}
}