fix printf to include trailing content
This commit is contained in:
@@ -13,13 +13,16 @@ export const sprintf = (str, values) => {
|
|||||||
// =>
|
// =>
|
||||||
// asd, line 20, ...
|
// asd, line 20, ...
|
||||||
const matches = str.matchAll(replacy);
|
const matches = str.matchAll(replacy);
|
||||||
return [...matches]
|
let lastScanned = 0;
|
||||||
|
const s = [...matches]
|
||||||
.map((m, idx) => {
|
.map((m, idx) => {
|
||||||
const cur = values[idx];
|
const cur = values[idx];
|
||||||
const val = m.groups.formatter == "x" ? `0x${cur.toString(16)}` : cur.toString();
|
const val = m.groups.formatter == "x" ? `0x${cur.toString(16)}` : cur.toString();
|
||||||
|
lastScanned = m.index + m[0].length;
|
||||||
return m.groups.pre + val;
|
return m.groups.pre + val;
|
||||||
})
|
})
|
||||||
.join("");
|
.join("");
|
||||||
|
return s + str.slice(lastScanned);
|
||||||
};
|
};
|
||||||
export const u16_swap = (x) => ((x & 0xff00) >> 8) | ((x & 0x00ff) << 8);
|
export const u16_swap = (x) => ((x & 0xff00) >> 8) | ((x & 0x00ff) << 8);
|
||||||
export const swap_endianness_u16 = (ptr) => {
|
export const swap_endianness_u16 = (ptr) => {
|
||||||
|
|||||||
Reference in New Issue
Block a user