{"_id":"@huggingface/gearhash-wasm","_rev":"4-a92538913e1a693680d6485b5a45eaa9","name":"@huggingface/gearhash-wasm","dist-tags":{"latest":"0.0.2"},"versions":{"0.0.1":{"name":"@huggingface/gearhash-wasm","version":"0.0.1","keywords":["gearhash","assemblyscript","assembly","wasm"],"_id":"@huggingface/gearhash-wasm@0.0.1","maintainers":[{"name":"julien-c","email":"chaumond@gmail.com"},{"name":"pierric","email":"pierrot007@gmail.com"},{"name":"coyotte508","email":"coyotte508@protonmail.com"},{"name":"xenova","email":"admin@xenova.com"}],"dist":{"shasum":"09834c31a21acbe4cb7085ec63de9ed6f196ffba","tarball":"https://registry.npmjs.org/@huggingface/gearhash-wasm/-/gearhash-wasm-0.0.1.tgz","fileCount":13,"integrity":"sha512-WcejF4aYsI+rH6bS3meuN2Sw/Qv64OTtsgvFPhUkQhAoxV03LO0OgnqrZJ6DJ/j5IG3SNwz3O8wALQE7J4aQVw==","signatures":[{"sig":"MEUCID24Psy/ATsBkKcKD4E6120BptBcxLQx2BKFFOtQr/IIAiEA9ZHKRAMeilcOq+Da8pcoaXZXSf9OtRPtDRDZQmWMxms=","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":490520},"main":"./build/release.js","type":"module","_from":"file:huggingface-gearhash-wasm-0.0.1.tgz","types":"./build/release.d.ts","exports":{".":{"types":"./build/release.d.ts","import":"./build/release.js"},"./wasm":{"import":"./build/release.wasm"},"./assembly":{"import":"./assembly/index.ts"}},"scripts":{"test":"vitest run","build":"pnpm run build:debug && npm run build:release","build:debug":"asc assembly/index.ts --target debug","build:release":"asc assembly/index.ts --target release"},"_npmUser":{"name":"coyotte508","actor":{"name":"coyotte508","type":"user","email":"coyotte508@protonmail.com"},"email":"coyotte508@protonmail.com"},"_resolved":"/tmp/5b89701cb02f688ca2ca38f018c4ca97/huggingface-gearhash-wasm-0.0.1.tgz","_integrity":"sha512-WcejF4aYsI+rH6bS3meuN2Sw/Qv64OTtsgvFPhUkQhAoxV03LO0OgnqrZJ6DJ/j5IG3SNwz3O8wALQE7J4aQVw==","_npmVersion":"10.9.2","description":"JS and WASM implementations of https://github.com/srijs/rust-gearhash","directories":{},"_nodeVersion":"22.15.1","_hasShrinkwrap":false,"devDependencies":{"assemblyscript":"0.27.36","@huggingface/splitmix64-wasm":"0.0.1"},"_npmOperationalInternal":{"tmp":"tmp/gearhash-wasm_0.0.1_1751976115982_0.22812683205542394","host":"s3://npm-registry-packages-npm-production"},"deprecated":"This package is deprecated in favor of gearhash-jit. Please migrate to gearhash-jit for better performance."},"0.0.2":{"name":"@huggingface/gearhash-wasm","version":"0.0.2","keywords":["gearhash","assemblyscript","assembly","wasm"],"_id":"@huggingface/gearhash-wasm@0.0.2","maintainers":[{"name":"julien-c","email":"chaumond@gmail.com"},{"name":"pierric","email":"pierrot007@gmail.com"},{"name":"coyotte508","email":"coyotte508@protonmail.com"},{"name":"xenova","email":"admin@xenova.com"},{"name":"gary149","email":"v@huggingface.co"}],"dist":{"shasum":"7ae999c4dccf976c392554b7ff3f62b3f51750cb","tarball":"https://registry.npmjs.org/@huggingface/gearhash-wasm/-/gearhash-wasm-0.0.2.tgz","fileCount":12,"integrity":"sha512-vJX3hR7CUzCBvJobfbZ/oU6XqtTAWzIFdIixN+4AgckPweNrCQ5imepBnRtzezfrgpKYCVqDvNm2rDSOemx4FA==","signatures":[{"sig":"MEYCIQCIzaQWY8zBNyjlfdN+kUyOUaQW1ygqDRMC+hKODagCUAIhAOK1T536ggwC5uQRCAaXzDq3DaBygMrwFLbXVJbMpm4+","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":489556},"main":"./build/release.js","type":"module","types":"./build/release.d.ts","exports":{".":{"types":"./build/release.d.ts","import":"./build/release.js"},"./wasm":{"import":"./build/release.wasm"},"./assembly":{"import":"./assembly/index.ts"}},"gitHead":"ce14006b9a7bf556073e3633bb7c770457c53779","scripts":{"test":"vitest run","build":"pnpm run build:debug && npm run build:release","prepare":"pnpm run build","build:debug":"asc assembly/index.ts --target debug","build:release":"asc assembly/index.ts --target release"},"_npmUser":{"name":"coyotte508","email":"coyotte508@protonmail.com"},"deprecated":"This package is deprecated in favor of gearhash-jit. Please migrate to gearhash-jit for better performance.","_npmVersion":"11.9.0","description":"JS and WASM implementations of https://github.com/srijs/rust-gearhash","directories":{},"_nodeVersion":"24.14.0","_hasShrinkwrap":false,"devDependencies":{"assemblyscript":"0.27.36","@huggingface/splitmix64-wasm":"workspace:*"},"_npmOperationalInternal":{"tmp":"tmp/gearhash-wasm_0.0.2_1776264271834_0.1582225055876234","host":"s3://npm-registry-packages-npm-production"}}},"time":{"created":"2025-07-08T12:01:55.889Z","modified":"2026-04-15T14:44:43.353Z","0.0.1":"2025-07-08T12:01:56.194Z","0.0.2":"2026-04-15T14:44:31.998Z"},"keywords":["gearhash","assemblyscript","assembly","wasm"],"description":"JS and WASM implementations of https://github.com/srijs/rust-gearhash","maintainers":[{"name":"coyotte508","email":"coyotte508@protonmail.com"},{"name":"gary149","email":"v@huggingface.co"},{"name":"julien-c","email":"chaumond@gmail.com"},{"name":"pierric","email":"pierrot007@gmail.com"},{"name":"xenova","email":"admin@xenova.com"}],"readme":"JS and WASM implementations of https://github.com/srijs/rust-gearhash\n\nUsing [AssemblyScript](https://www.assemblyscript.org/) to generate a lean WASM.\n\n## Usage\n\n```javascript\nimport { nextMatch } from '@huggingface/gearhash-wasm';\n\n// Create a Uint8Array of data to search through\nconst data = new Uint8Array(1000000); // Example: 1MB of data\n// ... fill data with your content ...\n\nconst mask = 0x0000d90003530000n; // Example mask as a BigInt, more 1s in binary repr => bigger chunks\n//^ it has 11 1s in binary, so chunks will be ~2048 long\nconst match = nextMatch(data, mask);\nconst allMatches = nextMatches(data, mask).matches;\n```\n\nThe `nextMatch` function takes two parameters:\n- `data`: A Uint8Array containing the data to search through\n- `mask`: A BigInt, the more 1s it has in its binary representation, the bigger the chunk\n\nThe function returns an object with the `position` (i32) and `hash` (u64) properties\n\nYou can continuously feed data like this:\n\n```javascript\nlet hash = 0n;\nconst mask = 0x0000d90003530000n;\n\nlet length = 0; // extra length not processed\nfor await (const chunk of dataSource) {\n  let index = 0;\n  while (1) {\n    let match = nextMatch(chunk.subArray(index), mask, hash);\n\n    if (match.position !== -1) {\n      console.log({\n        length: match.position + length,\n        hash: match.hash\n      })\n\n      index += match.position;\n      length = 0;\n      hash = 0n;\n    } else {\n      length += chunk.length - index;\n      break;\n    }\n  }\n}\n\nconsole.log(length, \"bytes without a match, ending hash: \", hash);\n```\n\nor, more performant with `nextMatches`:\n\n```javascript\nlet hash = 0n;\nconst mask = 0x0000d90003530000n;\n\nlet length = 0;\nfor await (const chunk of dataSource) {\n  const result = nextMatches(chunk, mask, hash);\n  let lastPosition = 0;\n  for (const match of result.matches) {\n    console.log({\n      length: match.position - lastPosition + length,\n      hash: match.hash\n    });\n\n    length = 0;\n    lastPosition = match.position;\n  }\n  length = result.remaining;\n  hash = result.hash;\n}\n\nconsole.log(length, \"bytes without a match, ending hash: \", hash);\n```\n\n## Possible improvements\n\nSIMD","readmeFilename":"README.md"}