# hex-lite

> isomorphic hex library in 256 bytes

Latest version **1.5.0** (published 2018-01-08) · MIT license · 0 weekly downloads

## Install

```sh
npm install hex-lite
pnpm add hex-lite
yarn add hex-lite
bun add hex-lite
```

## Health

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

Positive: esm support; no vulnerabilities.

Warnings: low downloads; no types.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.5.0 |
| Published | 2018-01-08 |
| First published | 2018-01-04 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | ESM + CommonJS |
| Dependencies | 0 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 4 |
| Maintainers | kevlened |
| Keywords | hex, buffer, ArrayBuffer, Uint8Array |

## Links

- npm: https://www.npmjs.com/package/hex-lite
- Repository: https://github.com/kevlened/hex-lite
- Homepage: https://github.com/kevlened/hex-lite#readme
- Issues: https://github.com/kevlened/hex-lite/issues
- npm.io page: https://npm.io/package/hex-lite

## Alternatives

- [flatbuffers](https://npm.io/package/flatbuffers.md) — 6.0M weekly downloads
- [jwt-simple](https://npm.io/package/jwt-simple.md) — 259.5K weekly downloads
- [@exodus/patch-broken-hermes-typed-arrays](https://npm.io/package/@exodus/patch-broken-hermes-typed-arrays.md) — 28.5K weekly downloads
- [@native-to-anchor/buffer-layout](https://npm.io/package/@native-to-anchor/buffer-layout.md) — 12.2K weekly downloads
- [binary-parser-encoder](https://npm.io/package/binary-parser-encoder.md) — 5.3K weekly downloads

## Recent versions

- 1.5.0 (latest) — 2018-01-08
- 1.4.0 — 2018-01-07
- 1.3.0 — 2018-01-06
- 1.2.1 — 2018-01-05
- 1.2.0 — 2018-01-05
- 1.1.0 — 2018-01-05
- 1.0.0 — 2018-01-04

## README

# hex-lite [![NPM](https://img.shields.io/npm/v/hex-lite.svg)](https://npmjs.com/package/hex-lite) [![Build](https://travis-ci.org/kevlened/hex-lite.svg?branch=master)](https://travis-ci.org/kevlened/hex-lite)
isomorphic hex library in 256 bytes

## Install

`npm install hex-lite`

## Usage

```javascript
const hex = require('hex-lite')

hex.toUint8Array('000f10ff000f10')
// new Uint8Array([0,15,16,255,0,15,16])

hex.fromUint8Array(new Uint8Array([0,15,16,255,0,15,16]))
// '000f10ff000f10'

hex.toBuffer('000f10ff000f10')
// ArrayBuffer

hex.fromBuffer(new Uint8Array([0,15,16,255,0,15,16]).buffer)
// '000f10ff000f10'
```

## Can it be smaller?

If you use ES6 imports with a bundler that supports tree-shaking, yes!

```javascript
import { fromUint8Array } from 'hex-lite'
```

## I wanna go fast!

The Node implementation is just a proxy to Node's `Buffer` object to be as fast as possible. The default browser implementation optimizes for size, so if you're looking for raw speed, import like this:

```javascript
import hex from 'hex-lite/fast/hex-lite.mjs'
```

#### Perf profile

```
⏱ browser performance on 1000 arrays or strings of size 10003:
hex.fromUint8Array: 810.422ms
hex.toUint8Array: 743.903ms
hex.fromBuffer: 798.264ms
hex.toBuffer: 584.592ms

⏱ fast browser performance on 1000 arrays or strings of size 10003:
hex.fromUint8Array: 222.453ms
hex.toUint8Array: 237.905ms
hex.fromBuffer: 223.078ms
hex.toBuffer: 231.342ms

⏱ node performance on 1000 arrays or strings of size 10003:
hex.fromUint8Array: 26.802ms
hex.toUint8Array: 32.461ms
hex.fromBuffer: 25.326ms
hex.toBuffer: 35.421ms
```

## License

MIT

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