-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathutility.js
42 lines (38 loc) · 1.12 KB
/
utility.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
var MAX_DUMP_DEPTH = 3;
function dumpObj(obj, name, indent, depth) {
if (depth > MAX_DUMP_DEPTH) {
return indent + name + ": <Maximum Depth Reached>\n";
}
if (typeof obj == "object") {
var child = null;
var output = indent + name + "\n";
indent += " ";
for (var item in obj)
{
try {
child = obj[item];
} catch (e) {
child = "<Unable to Evaluate>";
}
if (typeof child == "object") {
output += dumpObj(child, item, indent, depth + 1);
} else {
output += indent + item + ": " + child + "\n";
}
}
return output;
} else {
return obj;
}
}
function div(op1, op2) {
return(op1 / op2 - op1 % op2 / op2);
}
function index_of(array,value) {
for (var index = 0; index < array.length; index++) {
if (array[index] == value) {
return index;
}
}
return -1;
}