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 🙏

© 2026 – Pkg Stats / Ryan Hefner

ihex

v1.0.1

Published

Parse Intel HEX files and load them into a Buffer. Zero runtime dependencies, ESM, TypeScript types.

Readme

ihex

Parse Intel HEX files and load them into a Buffer.

  • Zero runtime dependencies (drops the abandoned line-reader).
  • ESM, with full TypeScript declarations.
  • Handles all standard record types (data, EOF, ESA, ELA, start-segment, start-linear).
  • Throws on malformed lines, checksum failures, and bounds violations (configurable).

Install

npm install ihex

Quick start

import { parseFile, applyRecordsToBuffer, loadFileIntoBuffer } from 'ihex';

// One-liner: parse a .hex and write it into a Buffer.
const buf = Buffer.alloc(64 * 1024);
const highWaterMark = await loadFileIntoBuffer('firmware.hex', buf);
console.log(`Wrote ${highWaterMark} bytes`);

// Or operate on records directly.
const records = await parseFile('firmware.hex');
for (const r of records) {
  // r.byteCount, r.address, r.type, r.data
}
applyRecordsToBuffer(records, buf);

API

parseFile(filename): Promise<IHexRecord[]>

Read a HEX file from disk and parse its records.

parseString(content): IHexRecord[]

Parse HEX content from a string or Buffer. Blank lines are skipped.

parseLine(line, lineNumber?): IHexRecord

Parse a single trimmed HEX line. Throws an IHexParseError on bad input.

applyRecordsToBuffer(records, buffer, opts?): number

Apply parsed records to a Buffer, honoring ExtendedLinearAddress and ExtendedSegmentAddress records. Stops at the first EndOfFile record by default. Returns the highest byte offset written.

Options:

  • stopAtEOF (default true): stop processing at the EOF record.
  • strictBounds (default true): throw if a data record would write past the buffer; when false, the offending bytes are silently truncated.

loadFileIntoBuffer(filename, buffer, opts?): Promise<number>

Convenience: parseFile + applyRecordsToBuffer in one call.

IHexRecordType

Enum-like object: Data, EndOfFile, ExtendedSegmentAddress, StartSegmentAddress, ExtendedLinearAddress, StartLinearAddress.

IHexParseError

Subclass of Error carrying lineNumber and line fields.

Migrating from 0.x

The 0.x API was a single callback-style function:

const ihex = require('ihex');
ihex('firmware.hex', buf, () => { /* done */ });

In 1.0:

import { loadFileIntoBuffer } from 'ihex';
await loadFileIntoBuffer('firmware.hex', buf);

Beyond the surface change, 1.0 also fixes several bugs in the original:

  • Uses Buffer.from() instead of the deprecated and unsafe new Buffer().
  • Honors ExtendedLinearAddress records, so files larger than 64 KB load to the correct addresses (the 0.x code silently ignored them).
  • Throws on malformed lines and checksum failures instead of console.log-ing and continuing.
  • Stops at the EndOfFile record instead of silently mishandling it.

Requirements

  • Node.js >= 22.

License

ISC.