From 784fc27a20f87b39d0b6570650880e979948ee3b Mon Sep 17 00:00:00 2001 From: DavidVentura Date: Fri, 26 Jan 2024 17:25:17 +0100 Subject: [PATCH] fix printf to include trailing content --- utils.js | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/utils.js b/utils.js index 5cfb6e1..f394b71 100644 --- a/utils.js +++ b/utils.js @@ -13,13 +13,16 @@ export const sprintf = (str, values) => { // => // asd, line 20, ... const matches = str.matchAll(replacy); - return [...matches] + let lastScanned = 0; + const s = [...matches] .map((m, idx) => { const cur = values[idx]; const val = m.groups.formatter == "x" ? `0x${cur.toString(16)}` : cur.toString(); + lastScanned = m.index + m[0].length; return m.groups.pre + val; }) .join(""); + return s + str.slice(lastScanned); }; export const u16_swap = (x) => ((x & 0xff00) >> 8) | ((x & 0x00ff) << 8); export const swap_endianness_u16 = (ptr) => {