From e5cd034e9ad82bf8335178fe73c930a191af443e Mon Sep 17 00:00:00 2001 From: Alistair Smith Date: Thu, 5 Feb 2026 06:41:25 -0800 Subject: [PATCH] Define seed in crc32 types (#26754) ### What does this PR do? Fixes #26711 ### How did you verify your code works? bun-types.test.ts integration test --- packages/bun-types/bun.d.ts | 2 +- test/integration/bun-types/fixture/hashing.ts | 6 ++++++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/packages/bun-types/bun.d.ts b/packages/bun-types/bun.d.ts index 418dbc87c9..5b34265536 100644 --- a/packages/bun-types/bun.d.ts +++ b/packages/bun-types/bun.d.ts @@ -2154,7 +2154,7 @@ declare module "bun" { interface Hash { wyhash: (data: string | ArrayBufferView | ArrayBuffer | SharedArrayBuffer, seed?: bigint) => bigint; adler32: (data: string | ArrayBufferView | ArrayBuffer | SharedArrayBuffer) => number; - crc32: (data: string | ArrayBufferView | ArrayBuffer | SharedArrayBuffer) => number; + crc32: (data: string | ArrayBufferView | ArrayBuffer | SharedArrayBuffer, seed?: number) => number; cityHash32: (data: string | ArrayBufferView | ArrayBuffer | SharedArrayBuffer) => number; cityHash64: (data: string | ArrayBufferView | ArrayBuffer | SharedArrayBuffer, seed?: bigint) => bigint; xxHash32: (data: string | ArrayBufferView | ArrayBuffer | SharedArrayBuffer, seed?: number) => number; diff --git a/test/integration/bun-types/fixture/hashing.ts b/test/integration/bun-types/fixture/hashing.ts index 553e0f1ff0..db937b2f20 100644 --- a/test/integration/bun-types/fixture/hashing.ts +++ b/test/integration/bun-types/fixture/hashing.ts @@ -1 +1,7 @@ Bun.hash.wyhash("asdf", 1234n); + +// https://github.com/oven-sh/bun/issues/26043 +// Bun.hash.crc32 accepts optional seed parameter for incremental CRC32 computation +let crc = 0; +crc = Bun.hash.crc32(new Uint8Array([1, 2, 3]), crc); +crc = Bun.hash.crc32(new Uint8Array([4, 5, 6]), crc);