Skip to content

Instantly share code, notes, and snippets.

@TheWass
TheWass / console.hex.ts
Created June 11, 2020 20:44 — forked from NielsLeenheer/console.hex.js
console.hex
/* eslint-disable */
// @ts-nocheck
interface Console {
hex(data: any): void;
}
console.hex = (d) => console.log((Object(d).buffer instanceof ArrayBuffer ? new Uint8Array(d.buffer) :
typeof d === 'string' ? (new TextEncoder('utf-8')).encode(d) :
new Uint8ClampedArray(d)).reduce((p, c, i, a) => p + (i % 16 === 0 ? i.toString(16).padStart(6, 0) + ' ' : ' ') +
c.toString(16).padStart(2, 0) + (i === a.length - 1 || i % 16 === 15 ?