# xxh3-ts

> xxhash implementation in pure typescript (using tc39 bigint), supports XXH64 & XXH3-128

Latest version **2.0.1** (published 2025-02-26) · BSD-2 Clause license · 0 weekly downloads

## Install

```sh
npm install xxh3-ts
pnpm add xxh3-ts
yarn add xxh3-ts
bun add xxh3-ts
```

## Health

**Score 30/100 (F)** — status: maintenance-mode.

Positive: has types; no vulnerabilities.

Warnings: low downloads; no esm support.

Negative: stale; low maintenance score.

## Facts

| | |
|---|---|
| Version | 2.0.1 |
| Published | 2025-02-26 |
| First published | 2019-12-21 |
| Weekly downloads | 0 |
| License | BSD-2 Clause |
| TypeScript types | bundled |
| Module format | CommonJS |
| Dependencies | 0 |
| Unpacked size | 35.5 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 11 |
| Author | casper@devdroplets.com |
| Maintainers | ferrisk |

## Links

- npm: https://www.npmjs.com/package/xxh3-ts
- Repository: https://github.com/i404788/xxh3-ts
- npm.io page: https://npm.io/package/xxh3-ts

## Recent versions

- 2.0.1 (latest) — 2025-02-26
- 2.0.0 — 2025-02-08
- 1.0.6 — 2023-01-23
- 1.0.5 — 2022-12-30
- 1.0.4 — 2022-12-30
- 1.0.3 — 2022-12-30
- 1.0.2 — 2019-12-22
- 1.0.1 — 2019-12-21
- 1.0.0 — 2019-12-21

## README

# xxh3-ts
xxhash implementation in pure typescript (using tc39 bigint), supports XXH64 & XXH3-128.
These algorithms require Node.js >=12.x, because of `Buffer::readBigUInt64LE`

## Usage:
```ts
import { XXH64 } from 'xxh3-ts';
import { Buffer } from 'buffer';

let hash: bigint = XXH64(Buffer.from(JSON.stringify(v)))
```
For conversion back to buffer it's recommended to use [bigint-buffer](https://www.npmjs.com/package/bigint-buffer) package or the following snippet:
```ts
function toBufferBE(num: bigint): Buffer {
  const hex = num.toString(16);
  // Padding *is* needed otherwise the last nibble will be dropped in an edge case
  return Buffer.from(hex.padStart(Math.ceil(hex.length/2) * 2, '0'), 'hex');
}
```

## Compatibility
XXH64 & XXH3-128 were derived from the [specifications](https://github.com/Cyan4973/xxHash/blob/v0.8.3/doc/xxhash_spec.md#xxh3-algorithm-overview) and is input/output compatible with [upstream v0.8.3](https://github.com/Cyan4973/xxHash/blob/v0.8.3)

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