Advertisement
Guest User

Untitled

a guest
Sep 23rd, 2019
98
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. console.hex = (d) => console.log((Object(d).buffer instanceof ArrayBuffer ? new Uint8Array(d.buffer) :
  2.     typeof d === 'string' ? (new TextEncoder('utf-8')).encode(d) :
  3.         new Uint8ClampedArray(d)).reduce((p, c, i, a) => p + (i % 16 === 0 ? i.toString(16).padStart(6, 0) + '  ' : ' ') +
  4.     c.toString(16).padStart(2, 0) + (i === a.length - 1 || i % 16 === 15 ?
  5.         ' '.repeat((15 - i % 16) * 3) + Array.from(a).splice(i - i % 16, 16).reduce((r, v) =>
  6.         r + (v > 31 && v < 127 || v > 159 ? String.fromCharCode(v) : '.'), '  ') + '\n' : ''), ''));
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement