Skip to content
/ xxh32 Public

Fastest 0.5kb(gzip) JavaScript implementation of the XXH32(xxHash32) algorithm.

License

Notifications You must be signed in to change notification settings

cgiosy/xxh32

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

30 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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/[email protected]/dist/index.bundle.js";
import { xxh32r } from "https://unpkg.com/[email protected]/dist/raw.bundle.js"; // for Uint8Array

or use dynamic import.

const { xxh32 } = await import("https://unpkg.com/[email protected]/dist/index.bundle.js");

Usage

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

const seed = 1234;
xxh32("test", seed) // === 1983208713

xxh32r(new Uint8Array(222)) // === 2025467952
xxh32r(new Uint8Array(222), seed) // === 2335345817

Streaming

import { xxh32sr } from "xxh32/dist/stream-raw.js";

or

import { xxh32sr } from "https://unpkg.com/[email protected]/dist/stream-raw.bundle.js";

Usage (Streaming)

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

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

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

About

Fastest 0.5kb(gzip) JavaScript implementation of the XXH32(xxHash32) algorithm.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published