npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

hexlook

v1.0.0

Published

Dumps data in hexadecimal format. Provides a single function to take an array of bytes and display it in hexadecimal form.

Downloads

2

Readme

hexlook

Dumps data in hexadecimal format.
Provides a single function to take an array of bytes and display it in hexadecimal form.

Install

npm i hexlook

Usage

For ESM

import hexlook from 'hexlook';

For CJS

const hexlook = require('hexlook');

string

// Output: 00000000  59 65 61 68 2c 20 69 74 27 73 20 6d 79 20 6c 69  |Yeah, it's my li|
//         00000010  66 65 2e 20 4d 79 20 6f 77 6e 20 77 6f 72 64 73  |fe. My own words|
//         00000020  2c 20 49 67 75 65 73 73 2e                       |, Iguess.|
const payload = 'Yeah, it\'s my life. My own words, Iguess.';
const dump = hexlook(payload);
console.log(dump);

Get only hex columns in one row

// 596561682c2069742773206d79206c6966652e204d79206f776e20776f7264732c204967756573732e
const payload = 'Yeah, it\'s my life. My own words, Iguess.';
const dump = hexlook(payload, {
  hexBlock: payload.length,
  hexGroup: 1,
  hexSep: '',
  offsetShow: false,
  asciiShow: false
});
console.log(dump);

0 byte

// Output: ''
const payload = [];
const dump = hexlook(Buffer.from(payload));
console.log(dump);

8 bytes

// Output: 00000000  01 02 03 04 05 06 07 08                          |........|
const payload = [0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08];
const dump = hexlook(Buffer.from(payload));
console.log(dump);

16 bytes w/ whale

// Output: 00000000  00 00 00 00 00 00 77 68 61 6c 65 00 00 00 00 00  |......whale.....|
const payload = [0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x77, 0x68, 0x61, 0x6c, 0x65, 0x00, 0x00, 0x00, 0x00, 0x00];
const dump = hexlook(Buffer.from(payload));
console.log(dump);

24 bytes w/ whale & octopus

// Output: 00000000  00 00 00 00 00 00 77 68 61 6c 65 00 00 00 00 00  |......whale.....|
//         00000010  00 6f 63 74 6f 70 75 73                          |.octopus|
const payload = [0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x77, 0x68, 0x61, 0x6c, 0x65, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x6f, 0x63, 0x74, 0x6f, 0x70, 0x75, 0x73];
const dump = hexlook(Buffer.from(payload));
console.log(dump);

asciiNull works

// Output: 00000000                                                   |empty|
const payload = [];
const dump = hexlook(Buffer.from(payload), {asciiNull: 'empty'});
console.log(dump);

hex(24 bytes w/ whale & octopus + asciiRender option)

// Output: 00000000  00 00 00 00 00 00 77 68 61 6c 65 00 00 00 00 00  |whale|
//         00000010  00 6f 63 74 6f 70 75 73                          |octopus|
const payload = [0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x77, 0x68, 0x61, 0x6c, 0x65, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x6f, 0x63, 0x74, 0x6f, 0x70, 0x75, 0x73];
const dump = hexlook(Buffer.from(payload), {
  // Convert unicode to characters.
  asciiRender: byte => {
    if (byte > 0x1f && byte < 0x7f)
      return String.fromCharCode(byte);
    else
      return '';
  }
});
console.log(dump);

24 bytes w/ whale & octopus + offsetWidth option

// Output: 00  00 00 00 00 00 00 77 68 61 6c 65 00 00 00 00 00  |......whale.....|
//         10  00 6f 63 74 6f 70 75 73                          |.octopus|
const payload = [0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x77, 0x68, 0x61, 0x6c, 0x65, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x6f, 0x63, 0x74, 0x6f, 0x70, 0x75, 0x73];
const dump = hexlook(Buffer.from(payload), {offsetWidth: 2});
console.log(dump);

Passing undefined parameter will result in an error

// Output: payload is unknown
try {
  const payload = undefined;
  hexlook(payload);
} catch(err) {
  console.error(err.message);
}

Passing null parameter will result in an error

// Output: payload is unknown
try {
  const payload = null;
  hexlook(payload);
} catch(err) {
  console.error(err.message);
}

Passing numeric parameter will result in an error

// Output: payload is unknown
try {
  const payload = 123;
  hexlook(payload);
} catch(err) {
  console.error(err.message);
}

Passing array parameter will result in an error

// Output: payload is unknown
try {
  const payload = [];
  hexlook(payload);
} catch(err) {
  console.error(err.message);
}

Passing object parameter will result in an error

// Output: payload is unknown
try {
  const payload = {};
  hexlook(payload);
} catch(err) {
  console.error(err.message);
}

Options

Author

Takuya Motoshima

License

MIT