From 936257c562b72047dd5f911aaea0c809e1a9dd97 Mon Sep 17 00:00:00 2001 From: DavidVentura Date: Sun, 28 Jan 2024 20:16:42 +0100 Subject: [PATCH] tolerate da dataview --- hexdump.js | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/hexdump.js b/hexdump.js index a4a328f..55b3d00 100644 --- a/hexdump.js +++ b/hexdump.js @@ -10,12 +10,15 @@ export const hexdump = (target, options) => { const ansiColor = options.hasOwnProperty("ansiColor") ? options.ansiColor : 0; let buffer; + if (target instanceof DataView) { + target = target.buffer; + } if (target instanceof ArrayBuffer) { if (length === undefined) length = target.byteLength; else length = Math.min(length, target.byteLength); buffer = target; } else { - throw "Gimme array buffer"; + throw "Gimme array buffer or DataView"; } const startAddress = 0;