From 4f82cd9c9eae184837e7faf15aa1f634178c6c9c Mon Sep 17 00:00:00 2001 From: n loewen Date: Thu, 3 Aug 2023 16:24:51 +0100 Subject: [PATCH] Turn on Jsdoc-based type checking --- jsconfig.json | 6 ++++++ logging.js | 18 +++++++++++++++++- 2 files changed, 23 insertions(+), 1 deletion(-) create mode 100644 jsconfig.json diff --git a/jsconfig.json b/jsconfig.json new file mode 100644 index 0000000..d0617e1 --- /dev/null +++ b/jsconfig.json @@ -0,0 +1,6 @@ +{ + "compilerOptions": { + "checkJs": true + }, + "exclude": ["node_modules", "**/node_modules/*"] +} \ No newline at end of file diff --git a/logging.js b/logging.js index 9695d4d..92f551a 100644 --- a/logging.js +++ b/logging.js @@ -1,3 +1,10 @@ +/** + * Display a table of memory locations. + * Call with [start] and [end] indices to display a range. + * @param {Uint8Array} mem - Memory to display + * @param {number} [start] - A start-index, in decimal + * @param {number} [end] - An end-index, in decimal + **/ const logMemory = (mem, start=0, end=mem.length) => { // This function can only handle // an even number of array entries @@ -15,7 +22,7 @@ const logMemory = (mem, start=0, end=mem.length) => { // Add a blank row every 4 lines: if (((i + 2) % 8) === 0) { if ((i < (mem.length - 2))) { - console.log(`│ │ │ │`); + console.log(`│ │ │ │`); } } } @@ -30,7 +37,16 @@ const logRunningHeader = () => { console.log( `└─────────────────────┘`); } +/** + * @param {number} num + * @returns {string} + */ const num2hex = (num) => num.toString(16).toUpperCase().padStart(2, "0"); + +/** + * @param {string} hex + * @returns {number} + */ const hex2num = (hex) => parseInt(hex, 16); module.exports = {