{"id":17014,"library":"hexer","title":"Hexer: Hexadecimal Dumper","description":"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.","status":"abandoned","version":"1.5.0","language":"javascript","source_language":"en","source_url":"git://github.com/jcorbin/hexer","tags":["javascript","hex","dump","hexdump"],"install":[{"cmd":"npm install hexer","lang":"bash","label":"npm"},{"cmd":"yarn add hexer","lang":"bash","label":"yarn"},{"cmd":"pnpm add hexer","lang":"bash","label":"pnpm"}],"dependencies":[],"imports":[{"note":"Hexer is a CommonJS-only package. Native ES module imports are not supported. The main export is a function for dumping buffers.","wrong":"import hex from 'hexer';","symbol":"hex","correct":"const hex = require('hexer');"},{"note":"Named exports like `Spy` are properties of the main CommonJS `hex` export, not separate ES modules.","wrong":"import { Spy } from 'hexer';","symbol":"hex.Spy","correct":"const hex = require('hexer');\n// ...\nhex.Spy(process.stdout);"},{"note":"Like `Spy`, `Transform` is a property of the main CommonJS `hex` export. It functions as a duplex stream.","wrong":"import { Transform } from 'hexer';","symbol":"hex.Transform","correct":"const hex = require('hexer');\n// ...\nhex.Transform();"}],"quickstart":{"code":"const hex = require('hexer');\nconst { Readable, Writable } = require('stream');\n\n// Example 1: Buffer to string\nconst someBuffer = Buffer.from('Hello, Hexer!');\nconsole.log('Buffer dump:\\n' + hex(someBuffer));\n\n// Example 2: Streaming transform\nconst inputData = Buffer.from('This is a test stream with some data.\\nAnother line here.');\nconst readableStream = new Readable({ read() {} });\n\nconsole.log('\\nStreaming transform:');\nreadableStream\n    .pipe(hex.Transform({ cols: 8, group: 4, headSep: '| ' }))\n    .pipe(new Writable({\n        write(chunk, encoding, callback) {\n            process.stdout.write(chunk.toString());\n            callback();\n        }\n    }));\n\nreadableStream.push(inputData.slice(0, 20));\nreadableStream.push(inputData.slice(20, 40));\nreadableStream.push(null); // End the stream\n","lang":"javascript","description":"Demonstrates basic usage of `hexer` to dump a Buffer to a string and to process a Readable stream with custom formatting options."},"warnings":[{"fix":"For ESM projects, use dynamic `import()` or consider a modern alternative like `hexy` that supports ESM. If using Node.js with `type: \"module\"` in `package.json`, you might need to wrap `require('hexer')` in an async function or use a compatibility layer if available.","message":"Hexer is a CommonJS-only package and does not provide native ES module (ESM) support. Attempting to `import` it in an ESM project will result in a 'Module not found' or similar error.","severity":"breaking","affected_versions":">=1.0.0"},{"fix":"Evaluate compatibility through testing in your specific Node.js environment. For new projects or those requiring long-term stability and modern features, consider more actively maintained alternatives.","message":"The package has not been updated in over 7 years, and its `engines.node` field specifies `>= 0.10.x`. While it might still function on newer Node.js versions, it is not officially tested or supported for them and may encounter unexpected compatibility issues or rely on deprecated Node.js APIs.","severity":"gotcha","affected_versions":">=1.5.0"}],"env_vars":null,"last_verified":"2026-04-22T00:00:00.000Z","next_check":"2026-07-21T00:00:00.000Z","problems":[{"fix":"Ensure you are using `const hex = require('hexer');` for CommonJS environments. The main `hex` function is the direct export of the module, while `Spy` and `Transform` are properties on it.","cause":"Attempting to use `hexer` as a default export function after incorrectly importing it using `import hex from 'hexer';` in an ESM context, or incorrectly destructuring `require('hexer')`.","error":"TypeError: hexer is not a function"},{"fix":"Either convert your project or specific file to CommonJS, or use `const hex = await import('hexer').then(m => m.default || m);` for dynamic ESM import, though full compatibility isn't guaranteed. It's often better to use a modern, ESM-compatible hex dumping library.","cause":"Attempting to `require('hexer')` in a Node.js environment where the current file or project is configured as an ES module (e.g., `\"type\": \"module\"` in `package.json`).","error":"ERR_REQUIRE_ESM: Must use import to load ES Module"}],"ecosystem":"npm","meta_description":null}