Hexer: Hexadecimal Dumper

1.5.0 · abandoned · verified Wed Apr 22

Hexer is a Node.js library for generating hexadecimal dumps of buffers and streams, offering synchronous, streaming, and CLI modes. Its primary function is to transform binary data into a human-readable hex format, similar to tools like `xxd`. The package provides various transform streams for different use cases, including spying on stream data, converting entire streams, or processing data in chunks. Key customization options include control over output formatting like line prefixes, column count, grouping, and custom decorators for byte representation. The current stable version is 1.5.0, which was last published over 7 years ago, indicating it is no longer actively maintained. This means it primarily supports older CommonJS (CJS) environments and Node.js versions (engines require `>= 0.10.x`) and lacks native ES module (ESM) support or recent updates to align with modern JavaScript practices. Alternatives like `hexy` exist that are more actively maintained and support modern Node.js and ESM.

Common errors

Warnings

Install

Imports

Quickstart

Demonstrates basic usage of `hexer` to dump a Buffer to a string and to process a Readable stream with custom formatting options.

const hex = require('hexer');
const { Readable, Writable } = require('stream');

// Example 1: Buffer to string
const someBuffer = Buffer.from('Hello, Hexer!');
console.log('Buffer dump:\n' + hex(someBuffer));

// Example 2: Streaming transform
const inputData = Buffer.from('This is a test stream with some data.\nAnother line here.');
const readableStream = new Readable({ read() {} });

console.log('\nStreaming transform:');
readableStream
    .pipe(hex.Transform({ cols: 8, group: 4, headSep: '| ' }))
    .pipe(new Writable({
        write(chunk, encoding, callback) {
            process.stdout.write(chunk.toString());
            callback();
        }
    }));

readableStream.push(inputData.slice(0, 20));
readableStream.push(inputData.slice(20, 40));
readableStream.push(null); // End the stream

view raw JSON →