{"_id":"gearhash-jit","_rev":"3-6c733c1fdcfcb6065536d80c21ad69c6","name":"gearhash-jit","dist-tags":{"latest":"1.0.2"},"versions":{"1.0.0":{"name":"gearhash-jit","version":"1.0.0","keywords":["gearhash","cdc","chunking","wasm"],"license":"MIT","_id":"gearhash-jit@1.0.0","maintainers":[{"name":"coyotte508","email":"coyotte508@protonmail.com"}],"dist":{"shasum":"2d2f0bb96ed4c69e737f87e3fbf3c90dd530125a","tarball":"https://registry.npmjs.org/gearhash-jit/-/gearhash-jit-1.0.0.tgz","fileCount":5,"integrity":"sha512-+tHYlKYLEiJwf2fj1k/YX3+YahswYltITKcqMRoeqzbZhBue1RAxBA2b5Rdqhpb+2nBF37TLkY0/vXInrX4WnA==","signatures":[{"sig":"MEQCIFo4XcgIVfKosRLOoDfbaHuyC903J+1dGjKwsKFYZQwQAiASP8tZlL/RQw0N6/d63dWenvUOExhDT3rK+UwuQmYD6g==","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":30979},"main":"./dist/index.js","type":"module","types":"./dist/index.d.ts","gitHead":"ce14006b9a7bf556073e3633bb7c770457c53779","scripts":{"test":"vitest run","build":"rolldown -c rolldown.config.js","typecheck":"tsc -p tsconfig.json"},"_npmUser":{"name":"coyotte508","email":"coyotte508@protonmail.com"},"_npmVersion":"11.9.0","description":"Fast GEAR hash with hand-written WASM i64 bytecode for content-defined chunking","directories":{},"sideEffects":false,"_nodeVersion":"24.14.0","_hasShrinkwrap":false,"packageManager":"pnpm@10.10.0","devDependencies":{"vitest":"^4.0.16","rolldown":"1.0.0-rc.15","typescript":"^6.0.0","@types/node":"^25.0.3","@oxc-node/cli":"^0.1.0","rolldown-plugin-dts":"^0.23.0"},"_npmOperationalInternal":{"tmp":"tmp/gearhash-jit_1.0.0_1776264252047_0.2296074636712453","host":"s3://npm-registry-packages-npm-production"}},"1.0.1":{"name":"gearhash-jit","version":"1.0.1","keywords":["gearhash","cdc","chunking","wasm"],"license":"MIT","_id":"gearhash-jit@1.0.1","maintainers":[{"name":"coyotte508","email":"coyotte508@protonmail.com"}],"dist":{"shasum":"506fa7019225c373a36f9c5bab720a23c10946a1","tarball":"https://registry.npmjs.org/gearhash-jit/-/gearhash-jit-1.0.1.tgz","fileCount":6,"integrity":"sha512-G3MFP6dwAdRcZK2WTyeqkJbZY3pfRmoDTm0T+9BBJpJhwN4LZikaYv3ZKEebZNNeWuPJ9eJJcEgzA3HOIQ4JZw==","signatures":[{"sig":"MEUCIGK97tvAYMrL8ODbHJ7lq0w8mL4dy9Aspa54gVQbmoGgAiEAgPemUNnthkKfafMMraNJ8jVRxgCPJNZaX2YdF9YeMQo=","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":32738},"main":"./dist/index.js","type":"module","types":"./dist/index.d.ts","gitHead":"3876ba8809754d7de4521087a8a71d5298d227ca","scripts":{"test":"vitest run","build":"rolldown -c rolldown.config.js","typecheck":"tsc -p tsconfig.json"},"_npmUser":{"name":"coyotte508","email":"coyotte508@protonmail.com"},"_npmVersion":"11.9.0","description":"Fast GEAR hash with hand-written WASM i64 bytecode for content-defined chunking","directories":{},"sideEffects":false,"_nodeVersion":"24.14.0","_hasShrinkwrap":false,"packageManager":"pnpm@10.10.0","devDependencies":{"vitest":"^4.0.16","rolldown":"1.0.0-rc.15","typescript":"^6.0.0","@types/node":"^25.0.3","@oxc-node/cli":"^0.1.0","rolldown-plugin-dts":"^0.23.0"},"_npmOperationalInternal":{"tmp":"tmp/gearhash-jit_1.0.1_1776264558229_0.03972079774786996","host":"s3://npm-registry-packages-npm-production"}},"1.0.2":{"name":"gearhash-jit","version":"1.0.2","description":"Fast GEAR hash with hand-written WASM i64 bytecode for content-defined chunking","keywords":["gearhash","cdc","chunking","wasm"],"license":"MIT","sideEffects":false,"scripts":{"prepare":"tshy","test":"vitest run"},"tshy":{"exports":{".":"./src/index.ts","./package.json":"./package.json"}},"devDependencies":{},"type":"module","exports":{".":{"import":{"types":"./dist/esm/index.d.ts","default":"./dist/esm/index.js"},"require":{"types":"./dist/commonjs/index.d.ts","default":"./dist/commonjs/index.js"}},"./package.json":"./package.json"},"main":"./dist/commonjs/index.js","types":"./dist/commonjs/index.d.ts","module":"./dist/esm/index.js","gitHead":"50b7fa1c13a5e02a67fafb1893271f96c4dbba2d","_id":"gearhash-jit@1.0.2","_nodeVersion":"24.14.0","_npmVersion":"11.9.0","dist":{"integrity":"sha512-UhzJL4KXSdqAKepy/tZwmi2Rcy0YMmtiC4DQS4SURCuIWdh8ECZtnXK2ePRMLigfB61hRKdLK/Vgg2bSw73izQ==","shasum":"8978ad06eba9e5f1b6689c27d43f3b7b4bdccebb","tarball":"https://registry.npmjs.org/gearhash-jit/-/gearhash-jit-1.0.2.tgz","fileCount":22,"unpackedSize":35504,"signatures":[{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEYCIQDw8vlmk3RofJBRbPGPGTnlRGV30mH3sgMNX1i+0KbVlgIhAPXsVWJ2BS4dvm6lE/VyLz/4F2Z83Ct9e0POY9N47qgq"}]},"_npmUser":{"name":"coyotte508","email":"coyotte508@protonmail.com"},"directories":{},"maintainers":[{"name":"coyotte508","email":"coyotte508@protonmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/gearhash-jit_1.0.2_1776266228726_0.5995350867578253"},"_hasShrinkwrap":false}},"time":{"created":"2026-04-15T14:44:11.932Z","modified":"2026-04-15T15:17:08.994Z","1.0.0":"2026-04-15T14:44:12.210Z","1.0.1":"2026-04-15T14:49:18.367Z","1.0.2":"2026-04-15T15:17:08.889Z"},"license":"MIT","keywords":["gearhash","cdc","chunking","wasm"],"description":"Fast GEAR hash with hand-written WASM i64 bytecode for content-defined chunking","maintainers":[{"name":"coyotte508","email":"coyotte508@protonmail.com"}],"readme":"# gearhash-jit\n\nFast [GEAR rolling hash](https://en.wikipedia.org/wiki/Rolling_hash) for content-defined chunking (CDC), using hand-written WebAssembly with native `i64` arithmetic.\n\nReplaces the deprecated `@huggingface/gearhash-wasm` (AssemblyScript) package.\n\n## How it works\n\nAt init time, a tiny WASM module (~120 bytes of bytecode) is generated and compiled synchronously. The inner loop uses native 64-bit integer operations (`i64.shl`, `i64.add`, `i64.and`) — single-cycle instructions that avoid the overhead of JavaScript `BigInt`.\n\n## Usage\n\n```typescript\nimport { Hasher } from 'gearhash-jit';\n\nconst mask = 0x0000d90003530000n; // CDC target mask\nconst hasher = new Hasher(mask);\n\n// Scan for a chunk boundary\nconst pos = hasher.nextMatch(buffer);\nif (pos !== -1) {\n  // Boundary found at byte `pos` (1-based)\n}\n\n// Read the rolling hash state (8 LE bytes, zero-copy)\nconsole.log(hasher.hash);\n\n// Reset for the next chunk\nhasher.resetHash();\n```\n\n### Streaming\n\nThe hash state carries over between `nextMatch` calls, so you can scan data in pieces:\n\n```typescript\nconst hasher = new Hasher(mask);\n\nfor (const chunk of dataSource) {\n  const pos = hasher.nextMatch(chunk);\n  if (pos !== -1) {\n    // Found boundary at `pos` within this chunk\n    hasher.resetHash();\n  }\n}\n```\n\n## API\n\n### `new Hasher(mask: bigint)`\n\nCreate a hasher with the given 64-bit CDC mask.\n\n### `hasher.nextMatch(buf: Uint8Array): number`\n\nScan `buf` for the next match. Returns a 1-based byte position, or `-1` if no match.\n\n### `hasher.hash: Uint8Array`\n\nThe current 64-bit rolling hash state as 8 little-endian bytes. Updated after every `nextMatch` call.\n\n### `hasher.resetHash(): void`\n\nReset the rolling hash to zero (call when starting a new chunk).\n","readmeFilename":"README.md"}