diff --git a/src/core/lib/Hex.mjs b/src/core/lib/Hex.mjs index 0108eabd..9c70e91c 100644 --- a/src/core/lib/Hex.mjs +++ b/src/core/lib/Hex.mjs @@ -36,11 +36,8 @@ export function toHex(data, delim=" ", padding=2, extraDelim="", lineSize=0) { for (let i = 0; i < data.length; i++) { const hex = data[i].toString(16).padStart(padding, "0"); - if (prepend) { - output += delim + hex; - } else { - output += hex + delim; - } + output += prepend ? delim + hex : hex + delim; + if (extraDelim) { output += extraDelim; } @@ -50,7 +47,7 @@ export function toHex(data, delim=" ", padding=2, extraDelim="", lineSize=0) { } } - // Remove the extraDelim at the end (if there is); + // Remove the extraDelim at the end (if there is one) // and remove the delim at the end, but if it's prepended there's nothing to remove const rTruncLen = extraDelim.length + (prepend ? 0 : delim.length); if (rTruncLen) { @@ -119,7 +116,7 @@ export function fromHex(data, delim="Auto", byteLen=2) { /** * To Hexadecimal delimiters. */ -export const TO_HEX_DELIM_OPTIONS = ["Space", "Percent", "Comma", "Semi-colon", "Colon", "Line feed", "CRLF", "0x", "\\x", "None"]; +export const TO_HEX_DELIM_OPTIONS = ["Space", "Percent", "Comma", "Semi-colon", "Colon", "Line feed", "CRLF", "0x", "0x with comma", "\\x", "None"]; /** diff --git a/src/core/operations/ToHex.mjs b/src/core/operations/ToHex.mjs index 25d4e059..2e97de8f 100644 --- a/src/core/operations/ToHex.mjs +++ b/src/core/operations/ToHex.mjs @@ -5,7 +5,7 @@ */ import Operation from "../Operation.mjs"; -import {toHex} from "../lib/Hex.mjs"; +import {toHex, TO_HEX_DELIM_OPTIONS} from "../lib/Hex.mjs"; import Utils from "../Utils.mjs"; /** @@ -29,7 +29,7 @@ class ToHex extends Operation { { name: "Delimiter", type: "option", - value: ["Space", "Percent", "Comma", "Semi-colon", "Colon", "Line feed", "CRLF", "0x", "0x with comma", "\\x", "None"] + value: TO_HEX_DELIM_OPTIONS }, { name: "Bytes per line",