# node-intelhex

> Intel Hex reader/writer

Latest version **2.0.4** (published 2018-05-19) · MIT license · 0 weekly downloads

## Install

```sh
npm install node-intelhex
pnpm add node-intelhex
yarn add node-intelhex
bun add node-intelhex
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 2.0.4 |
| Published | 2018-05-19 |
| First published | 2016-10-10 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 5 |
| Unpacked size | 279.9 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 0 |
| Author | Jim Baldwin |
| Maintainers | jmbldwn |
| Keywords | intel, hex |

## Links

- npm: https://www.npmjs.com/package/node-intelhex
- Repository: https://github.com/Antimatter/node-intel-hex
- Homepage: https://github.com/Antimatter/node-intel-hex#readme
- Issues: https://github.com/Antimatter/node-intel-hex/issues
- npm.io page: https://npm.io/package/node-intelhex

## Dependencies (5)

- [fs-extra](https://npm.io/package/fs-extra.md) ^6.0.1
- [callbackify](https://npm.io/package/callbackify.md) ^1.1.0
- [buffer-equal](https://npm.io/package/buffer-equal.md) ^0.0.1
- [event-stream](https://npm.io/package/event-stream.md) ^3.3.4
- [async-promise-wrapper](https://npm.io/package/async-promise-wrapper.md) ^1.0.0

## Alternatives

- [postcss-color-hex-alpha](https://npm.io/package/postcss-color-hex-alpha.md) — 6.4M weekly downloads
- [randomcolor](https://npm.io/package/randomcolor.md) — 348.0K weekly downloads
- [bows](https://npm.io/package/bows.md) — 1.3K weekly downloads
- [ep_prefer_color_scheme](https://npm.io/package/ep_prefer_color_scheme.md) — 260 weekly downloads
- [coc-yank](https://npm.io/package/coc-yank.md) — 61 weekly downloads

## Recent versions

- 2.0.4 (latest) — 2018-05-19
- 2.0.3 — 2018-05-18
- 2.0.2 — 2018-05-18
- 0.0.1-security — 2016-10-10

## README

# node-intelhex

An asynchronous, promise-based, reader/writer module for Intel Hex files for [node](http://nodejs.org).

  [![NPM Version][npm-image]][npm-url]
  [![NPM Downloads][downloads-image]][downloads-url]
  [![Linux Build][travis-image]][travis-url]
  [![Windows Build][appveyor-image]][appveyor-url]
  [![Test Coverage][coveralls-image]][coveralls-url]


# Installation
```bash
$ npm install node-intelhex
```
# Features
* Asynchronous using ES6 Promises
* High-level functions to transfer node Buffer objects to files and back
* Low-level functions to write/parse files a line at a time
# Usage
```js
const hex = require('node-intelhex');
```
## readFile(filename, options, callback~opt~)

Reads "filename" asynchronously, returns an object with a node Buffer along with the starting address.  If the file contains discontinuous data, gaps are filled with zeroes automatically.
```js
{
    data: Buffer,
    address: number
}
```

If no callback specified, returns a Promise

The "options" argument contains an object that can specify additional options:
```js
{
    progress: function,
    info: function
}
```
#### progress:
A callback to monitor progress.  Receives a number representing percentage complete.  Only called when percentage changes.
#### info:
A callback to receive informational messages during parsing.  Mostly for debug purposes.
### Example
```js
hex
    .readFile(
        'test/test.hex',
        {
            progress: percent => process.stdout.write('\r          \r' + percent + '%'),
            info: message => console.log('\r' + info + '\n')
        }
    )
    .then(result => {
//      {
//          address: <address of first byte in file>, 
//          buffer: <bytes read from file>
//      }
    })
    .catch(error => {
        // handle error
    });
```
## writeFile(filename, address, data, options, callback~opt~)

Writes the buffer in "data" to file "filename", with starting address "address".

Optional callback or Promise resolution on completion (after flushing).

The "options" argument contains an object that can specify additional options:
```js
{
    progress: function
}
```
#### progress:
A callback to monitor progress.  Receives a number representing percentage complete.  Only called when percentage changes.
### Example
```js
hex
    .writeFile('test/test.out.hex', address, data)
    .then(() => {
        // all done
    })
    .catch(error => {
        // handle error (mostly like from fs)
    });
```
## setLineBytes(num)
Set the number of bytes per line to num.  Default is 32.
## bufferReader(data)
Returns an object that takes a Buffer and starting address and produces Intel Hex lines one at a time until complete.
```js
// create reader
let br = hex.bufferReader(address, data);

// pull next record string
br.getNextRecord()

// end of buffer?
br.eof()

// length of buffer
br.length()

// num bytes read
br.bytesRead()

---
_Source: https://npm.io/package/node-intelhex · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
