diff options
author | Frederick Muriuki Muriithi | 2025-05-28 13:29:42 -0500 |
---|---|---|
committer | Frederick Muriuki Muriithi | 2025-05-28 13:29:42 -0500 |
commit | 9f2ddd603444f9a27bdebca2fd4435c6d5bb7411 (patch) | |
tree | 17ea63731eadaef6e45f0e85ba3ff58466e01c85 /uploader/static/js | |
parent | 979620f6ccf816170e01c7b92c71a8f4c3ce3e01 (diff) | |
download | gn-uploader-9f2ddd603444f9a27bdebca2fd4435c6d5bb7411.tar.gz |
Add javascript debugging function.
Diffstat (limited to 'uploader/static/js')
-rw-r--r-- | uploader/static/js/debug.js | 40 |
1 files changed, 40 insertions, 0 deletions
diff --git a/uploader/static/js/debug.js b/uploader/static/js/debug.js new file mode 100644 index 0000000..eb01209 --- /dev/null +++ b/uploader/static/js/debug.js @@ -0,0 +1,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; +} |