blob: eb01209996db3f2779de707a5684e353c8f4aff6 (
about) (
plain)
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
|
/**
* The entire purpose of this function is for use to debug values inline
* without changing the flow of the code too much.
*
* This **MUST** be a non-arrow function to allow access to the `arguments`
* object.
*
* This function expects at least one argument.
*
* If more than one argument is provided, then:
* a) the last argument is considered the value, and will be returned
* b) all other arguments will be converted to string and output
*
* If only one argument is provided, it is considered the value, and will be
* returned.
*
* Zero arguments is an error condition.
**/
function __pk__(val) {
/* Handle zero arguments */
if (arguments.length < 1) {
throw new Error("Invalid arguments: Expected at least one argument.");
}
msg = "/********** DEBUG **********/";
if (arguments.length > 1) {
msg = Array.from(
arguments
).slice(
0,
arguments.length - 1
).map((val) => {
return String(val);
}).join("; ")
}
value = arguments[arguments.length - 1];
console.debug("/********** " + msg + " **********/", value);
return value;
}
|