/**
* 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;
}