MCPcopy Create free account
hub / github.com/GamerHack/GamerHack.github.io / hexdump

Function hexdump

restore/702/utils.js:44–59  ·  view source on GitHub ↗
(data)

Source from the content-addressed store, hash-verified

42}
43
44function hexdump(data) {
45 if (typeof data.BYTES_PER_ELEMENT !== 'undefined')
46 data = Array.from(data);
47
48 var lines = [];
49 for (var i = 0; i < data.length; i += 16) {
50 var chunk = data.slice(i, i + 16);
51 var parts = chunk.map(hex);
52 if (parts.length > 8)
53 parts.splice(8, 0, ' ');
54 lines.push("" + i.toString(16) + " : " + parts.join(' '));
55 // lines.push(parts.join(' '));
56 }
57
58 return lines.join('\n');
59}
60
61function buf2hex(buffer) {
62 return Array.prototype.map.call(new Uint8Array(buffer), x => ('00' + x.toString(16)).slice(-2)).join('');

Callers

nothing calls this directly

Calls 1

toStringMethod · 0.45

Tested by

no test coverage detected