From 4fd3cb912522613b6c9124463fd2fd193451dec0 Mon Sep 17 00:00:00 2001 From: DavidVentura Date: Sun, 28 Jan 2024 20:14:50 +0100 Subject: [PATCH] u32 swap --- utils.js | 2 ++ 1 file changed, 2 insertions(+) diff --git a/utils.js b/utils.js index f394b71..f9cbbbc 100644 --- a/utils.js +++ b/utils.js @@ -24,6 +24,8 @@ export const sprintf = (str, values) => { .join(""); return s + str.slice(lastScanned); }; +export const u32_swap = (x) => + ((x & 0xff000000) >> 24) | ((x & 0xff0000) >> 8) | ((x & 0xff00) << 8) | ((x & 0xff) << 24); export const u16_swap = (x) => ((x & 0xff00) >> 8) | ((x & 0x00ff) << 8); export const swap_endianness_u16 = (ptr) => { const bytes = ptr.readU16();