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

hexer

v1.5.0

Published

Hex Dumper (streaming, sync, and cli)

Downloads

2,108,932

Readme

CLI Usage

$ </bin/ls hexer

API Usage

Simple mode: buffer -> string

Got as buffer? We can render it:

var hex = require('hexer');
console.log(hex(someBuffer));

Simply steram spy mode: in -> hex.Spy (->sink) -> out

Want to see what's going through a stream?

var hex = require('hexer');

stream
    .pipe(hex.Spy(process.stdout)) // argument is where to dump to
    .pipe(somewhere);              // normal output flows through

Simple streaming mode: in -> hex.Transform -> out

Got a stream? We can render it:

var hex = require('hexer');
process.stdin
    .pipe(hex.Transform())
    .pipe(process.stdout);

Chunked streaming mode: in -> hex.ChunkedTransform -> out

Got a stream? We can render each of its chunks:

var hex = require('hexer');
process.stdin
    .pipe(hex.ChunkedTransform())
    .pipe(process.stdout);

Advanced chunked streaming mode

Finally you can control the sessionization yourself if that makes sense:

var hex = require('hexer');
var hexer = hex.Transform();
hexer.pipe(process.stdout);

process.stdin.on('data', function onData(chunk) {
    if (decideToReset(chunk)) {
        hexer.reset();
    }
    hexer.write(chunk);
});

However that example is a bit contrived, a more realistic example would be:

var hex = require('hexer');
var hexer = hex.Transform();
hexer.pipe(process.stdout);

process.stdin.on('data', function onData(chunk) {
    var i = findBoundary(chunk);
    while (i > 0) {
        hexer.write(chunk.slice(0, i));
        hexer.reset();
        chunk = chunk.slice(i);
        i = findBoundary(chunk);
    }
    if (chunk.length) {
        hexer.write(chunk);
    }
});

Options

  • prefix: a string that will be printed at the beginning of every line. (default empty string, "")

  • cols: the number of bytes to display on each line (default 16)

  • group: the number of bytes to display adjacently (default 2)

  • groupSeparator: a string that appears between byte groups (default one space " ")

  • headSep: a string that appears between the offset column and the byte column (default colon space, ": ")

  • divide: a string that appears between the byte value column and the character representation column (default two spaces, " ")

  • gutter: the minimum width of the gutter, the region on the left that contains the byte offset that each line starts with. (default 0)

  • offsetWidth: the minimum number of digits to display in the byte offset column.

  • decorateHexen(totalOffset, screenOffset, hexen): A function that has an opportunity to alter the numeric representation of a byte. Decoration is typically used to change the color of the byte based on its position in the stream or position in the line.

  • decorateHuman(totalOffset, screenOffset, human, byte): A function that has an opportunity to alter the appearance of a given human-readable representation of a byte. Decoration is typically used to change the color of the byte based on its position in the stream, position on the line, its representation, or its value.

  • renderHexen(byte): a function that accepts a byte value and returns a hexen readable, two character representation of that byte. By default, the hexen representation is lower-case zero-padded hex.

  • renderHuman(byte): a function that accepts a byte value and returns a human readable, single character representation of that byte. By default, the human representation is the character itself for all printable ASCII characters, and a period "." for control characters and EASCII bytes.

  • emptyHexen: a two character representation of a non-existant byte at a particular offset for the byte value representation. (default spaces, " ")

  • emptyHuman: the representation of a non-existant byte in the human readable characters column (default null string, "")

  • nullHuman: if an entire buffer or stream is empty, the default behavior is to represent it as an empty string or stream. With this option, the empty line will be expressly rendered, with offset zero, empty byte columns, and this string in the human readable characters section.

  • colored: if set true, enables ANSI coloring of output

License and Copyright

Copyright (c) 2015 Joshua T Corbin and contributors. All rights reserved. MIT License.