open-index/open-npm huggingface dataset:
npm package: @jadujoel/siphash-napi
Description: SipHash-2-4 via Rust napi-rs bindings
Latest version: 0.1.5

# siphash-napi

Fast [SipHash-2-4](https://131002.net/siphash/) for Node.js and Bun, backed by a native Rust extension via [napi-rs](https://napi.rs/).

## Installation

```sh
# npm
npm install siphash-napi

# bun
bun add siphash-napi
```

Pre-built native binaries are bundled for the following targets:

| Platform | Architecture |
|---|---|
| macOS | x64, arm64 |
| Linux (glibc) | x64, arm64 |
| Linux (musl) | x64, arm64 |
| Windows | x64, arm64 |

## API

```ts
// Hash a Buffer with the default key (0, 0)
function siphash(data: Buffer): bigint

// Hash a Buffer with a custom 128-bit key supplied as two 64-bit BigInt halves
function siphashWithKey(data: Buffer, key0: bigint, key1: bigint): bigint

// Hash a file by path, reading in 8 KiB chunks (no full file load into memory)
function siphashFile(path: string): bigint
```

All functions return a `bigint` representing the unsigned 64-bit hash value.

## Usage

### Node.js (CommonJS)

```js
const { siphash, siphashWithKey, siphashFile } = require('siphash-napi')

const hash = siphash(Buffer.from('hello'))
console.log(hash) // 7659893686435503compute (bigint)

// Custom key
const keyed = siphashWithKey(Buffer.from('hello'), 1n, 2n)

// Hash a file
const fileHash = siphashFile('/path/to/file.bin')
```

### Node.js (ESM)

```js
import { siphash, siphashWithKey, siphashFile } from 'siphash-napi'

const hash = siphash(Buffer.from('hello'))

const keyed = siphashWithKey(Buffer.from('hello'), 1n, 2n)

const fileHash = siphashFile('/path/to/file.bin')
```

### TypeScript

```ts
import { siphash, siphashWithKey, siphashFile } from 'siphash-napi'

const hash: bigint = siphash(Buffer.from('hello'))

const keyed: bigint = siphashWithKey(Buffer.from('hello'), 1n, 2n)

const fileHash: bigint = siphashFile('/path/to/file.bin')
```

### Bun

```ts
import { siphash, siphashWithKey, siphashFile } from 'siphash-napi'

const hash = siphash(Buffer.from('hello'))

// Use as a map/cache key
const cache = new Map<bigint, string>()
cache.set(siphash(Buffer.from('key')), 'value')
```

## Notes

- **Default key**: `siphash()` uses the zero key `(0, 0)`. This is suitable for non-cryptographic use cases such as hash tables and content deduplication. Do not rely on SipHash for cryptographic security.
- **Custom key**: Use `siphashWithKey(data, key0, key1)` when you need a secret or per-instance key to prevent hash-flooding attacks.
- **File hashing**: `siphashFile()` streams the file in 8 KiB chunks, so arbitrarily large files can be hashed without loading them fully into memory.
- **Return type**: All functions return a `bigint`. Use `.toString()` or `.toString(16)` if you need a string representation.

## Building from source

Requires Rust and the [napi-rs CLI](https://napi.rs/docs/introduction/getting-started).

```sh
npm install
npm run build
```

For a debug build:

```sh
npm run build:debug
```
npm package: @jadujoel/siphash-napi-linux-arm64-gnu
Description: SipHash-2-4 via Rust napi-rs bindings
Latest version: 0.1.5

# `@jadujoel/siphash-napi-linux-arm64-gnu`

This is the **aarch64-unknown-linux-gnu** binary for `@jadujoel/siphash-napi`
npm package: @jadujoel/siphash-napi-linux-arm64-musl
Description: SipHash-2-4 via Rust napi-rs bindings
Latest version: 0.1.5

# `@jadujoel/siphash-napi-linux-arm64-musl`

This is the **aarch64-unknown-linux-musl** binary for `@jadujoel/siphash-napi`
npm package: @jadujoel/siphash-napi-linux-x64-gnu
Description: SipHash-2-4 via Rust napi-rs bindings
Latest version: 0.1.5

# `@jadujoel/siphash-napi-linux-x64-gnu`

This is the **x86_64-unknown-linux-gnu** binary for `@jadujoel/siphash-napi`
npm package: @jadujoel/siphash-napi-linux-x64-musl
Description: SipHash-2-4 via Rust napi-rs bindings
Latest version: 0.1.5

# `@jadujoel/siphash-napi-linux-x64-musl`

This is the **x86_64-unknown-linux-musl** binary for `@jadujoel/siphash-napi`
npm package: @jadujoel/siphash-napi-win32-arm64-msvc
Description: SipHash-2-4 via Rust napi-rs bindings
Latest version: 0.1.5

# `@jadujoel/siphash-napi-win32-arm64-msvc`

This is the **aarch64-pc-windows-msvc** binary for `@jadujoel/siphash-napi`
npm package: @jadujoel/siphash-napi-win32-x64-msvc
Description: SipHash-2-4 via Rust napi-rs bindings
Latest version: 0.1.5

# `@jadujoel/siphash-napi-win32-x64-msvc`

This is the **x86_64-pc-windows-msvc** binary for `@jadujoel/siphash-napi`
npm package: @jadujoel/uniform-audio-param
Description: Cross-browser polyfill that normalizes `AudioParam` behavior across Chromium, Firefox, and WebKit.
Latest version: 0.0.2

# @jadujoel/uniform-audio-param

Cross-browser polyfill that normalizes `AudioParam` behavior across Chromium, Firefox, and WebKit.

## What it does

- **`cancelAndHoldAtTime`** — Polyfills the missing method in Firefox by tracking scheduled automation events and computing the held value mathematically.
- **`getScheduledValueAtTime`** — Utility to read the computed value of an AudioParam at any point in time, even before rendering.

Two flavors are provided:

- **Auto-patching** (default import) — patches `AudioParam.prototype` on import. Zero config.
- **Manual** (`/manual` import) — polyfill individual `AudioParam` instances explicitly, avoiding prototype monkey-patching.

## Install

### npm / bun / yarn / pnpm

```bash
npm install @jadujoel/uniform-audio-param
```

Then import it at the top of your app (side-effect import):

```js
import "@jadujoel/uniform-audio-param";
```

### CDN (script tag)

Load it directly from [unpkg](https://unpkg.com) or [jsDelivr](https://www.jsdelivr.com):

```html
<!-- unpkg -->
<script src="https://unpkg.com/@jadujoel/uniform-audio-param"></script>

<!-- jsDelivr -->
<script src="https://cdn.jsdelivr.net/npm/@jadujoel/uniform-audio-param"></script>
```

Or as an ES module:

```html
<script type="module">
  import "https://unpkg.com/@jadujoel/uniform-audio-param?module";
</script>
```

### Usage (auto-patching)

Once loaded (via import or script tag), the polyfill patches `AudioParam.prototype` automatically. Use the Web Audio API as normal:

```js
const ctx = new AudioContext();
const osc = ctx.createOscillator();
const gain = ctx.createGain();
osc.connect(gain).connect(ctx.destination);

gain.gain.setValueAtTime(1, ctx.currentTime);
gain.gain.linearRampToValueAtTime(0, ctx.currentTime + 1);

// cancelAndHoldAtTime now works in Firefox too
gain.gain.cancelAndHoldAtTime(ctx.currentTime + 0.5);
```

### Usage (manual)

If you prefer not to patch `AudioParam.prototype`, import from `@jadujoel/uniform-audio-param/manual` and polyfill individual params:

```js
import { polyfillAudioParam, polyfillAudioNode } from "@jadujoel/uniform-audio-param/manual";

const ctx = new AudioContext();
const gain = ctx.createGain();

// Polyfill a single AudioParam
polyfillAudioParam(gain.gain);

// Or polyfill all AudioParams on a node at once
const biquad = ctx.createBiquadFilter();
polyfillAudioNode(biquad); // patches frequency, detune, Q, gain

gain.gain.setValueAtTime(1, ctx.currentTime);
gain.gain.linearRampToValueAtTime(0, ctx.currentTime + 1);
gain.gain.cancelAndHoldAtTime(ctx.currentTime + 0.5);
```

## Known limitations

- **`automationRate "k-rate"`** — No polyfill possible (engine-internal behavior).
- **`.value` getter before rendering** — Cannot be polyfilled without breaking Firefox's spec-correct behavior. Use `getScheduledValueAtTime()` instead.

## Development

```bash
bun install
bun run build     # build to dist/
bun test          # run polyfill tests
```