xxh32
TypeScript icon, indicating that this package has built-in type declarations

1.4.0 • Public • Published

xxh32

Fastest 0.5kb(gzip) JavaScript implementation of Cyan4973's XXH32 (xxHash32) algorithm.

Installation

npm i xxh32

and import it:

import xxh32 from "xxh32";

Without installation

You can directly import URL in ES Modules. (works in Browser, Deno)

import xxh32 from "https://unpkg.com/xxh32@1.4.0/dist/index.bundle.js";

or use dynamic import.

const { default: xxh32 } = await import("https://unpkg.com/xxh32@1.4.0/dist/index.bundle.js");

Usage

xxh32(new Uint8Array(222)) // === 2025467952

xxh32(new TextEncoder().encode("test")) // === 1042293711

const seed = 1234;
xxh32(new Uint8Array(222), seed) // === 2335345817

Streaming

import xxh32s from "xxh32/dist/stream.js";

or

import xxh32s from "https://unpkg.com/xxh32@1.4.0/dist/stream.bundle.js";

Usage (Streaming)

xxh32s().update(new Uint8Array(222)).digest() // === 2025467952

xxh32s()
  .update(new TextEncoder().encode("te"))
  .update(new TextEncoder().encode("st"))
  .digest() // === 1042293711

const seed = 1234;
xxh32s(seed)
  .update(new Uint8Array(111))
  .update(new Uint8Array(111))
  .digest() // === 2335345817

Package Sidebar

Install

npm i xxh32

Weekly Downloads

3

Version

1.4.0

License

MIT

Unpacked Size

13.7 kB

Total Files

9

Last publish

Collaborators

  • cgiosy