{"_id":"farmhashjs","_rev":"3-4a7c54055dda0e5f0acb3e493d7495d1","name":"farmhashjs","dist-tags":{"latest":"1.0.1"},"versions":{"1.0.0":{"name":"farmhashjs","version":"1.0.0","keywords":["farmhash","hash","fingerprint","hash64","hash32","cityhash","murmurhash","google"],"author":{"name":"Crisp IM SAS"},"license":"Apache-2.0","_id":"farmhashjs@1.0.0","maintainers":[{"name":"baptistejamin","email":"baptistejamin@gmail.com"}],"homepage":"https://github.com/crisp-oss/farmhash-js#readme","bugs":{"url":"https://github.com/crisp-oss/farmhash-js/issues"},"dist":{"shasum":"dc82b6886a50c235928d7c5285a76fd9fbf738e0","tarball":"https://registry.npmjs.org/farmhashjs/-/farmhashjs-1.0.0.tgz","fileCount":8,"integrity":"sha512-w22xQSOroY9Vw57RKu3DsA1xNPkAIHIYA0HsjgWYvXZLRaeM+gaUGiGmylRHbgZnutPFnqsV92fJiMbUdkjKEA==","signatures":[{"sig":"MEUCIEMRWIRZDVgL3jrL5taRtVHXJDMhau5x59WD+ZHnhUebAiEAmo/Y7qB2CD/rqw7Q42fUiItT0meH6+75FRgdFbeHASA=","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":97223},"main":"./dist/index.js","type":"module","types":"./dist/index.d.ts","module":"./dist/index.js","engines":{"node":">=16"},"exports":{".":{"types":"./dist/index.d.ts","import":"./dist/index.js"}},"gitHead":"adc5d1488d089251f7dd386c84b212225dc1549d","scripts":{"test":"node --import tsx/esm test/index.test.ts","build":"tsc","benchmark":"node --import tsx/esm test/benchmark.ts","prepublishOnly":"npm run build"},"_npmUser":{"name":"baptistejamin","email":"baptistejamin@gmail.com"},"repository":{"url":"git+https://github.com/crisp-oss/farmhash-js.git","type":"git"},"_npmVersion":"11.6.1","description":"Pure JavaScript implementation of Google's FarmHash - compatible with farmhash v3.x and v5.x","directories":{},"_nodeVersion":"24.11.0","_hasShrinkwrap":false,"devDependencies":{"tsx":"4.21.0","farmhash":"3.3.1","typescript":"5.9.3","@types/node":"25.5.0","farmhash-modern":"npm:farmhash@5.0.0"},"_npmOperationalInternal":{"tmp":"tmp/farmhashjs_1.0.0_1775028294975_0.38320964623596243","host":"s3://npm-registry-packages-npm-production"}},"1.0.1":{"name":"farmhashjs","version":"1.0.1","keywords":["farmhash","hash","fingerprint","hash64","hash32","cityhash","murmurhash","google"],"author":{"name":"Crisp IM SAS"},"license":"Apache-2.0","_id":"farmhashjs@1.0.1","maintainers":[{"name":"baptistejamin","email":"baptistejamin@gmail.com"}],"homepage":"https://github.com/crisp-oss/farmhash-js#readme","bugs":{"url":"https://github.com/crisp-oss/farmhash-js/issues"},"dist":{"shasum":"d603fc6157a9c23120226dc805eee94c554f8256","tarball":"https://registry.npmjs.org/farmhashjs/-/farmhashjs-1.0.1.tgz","fileCount":8,"integrity":"sha512-xqkt5No1ejw8OFi1o1R88trBTraB5aAqKox3nLiwNoINoVPNaZqFL95XlWsBOZNx1LgNopPg0OUxX940tzEh0w==","signatures":[{"sig":"MEUCIFp6oPARhXfIZoH/Jay4yAOECYTOwHv65gBjrqtxViCKAiEAhHHckAEdjA9CJDsNsOo2BJq7W6aQ9VmabGxGTmHJNHk=","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":140019},"main":"./dist/index.js","type":"module","types":"./dist/index.d.ts","module":"./dist/index.js","engines":{"node":">=16"},"exports":{".":{"types":"./dist/index.d.ts","import":"./dist/index.js"}},"gitHead":"7cce61d94fc4e7b1c65ab8b7d1f66ba2cb9b5c6a","scripts":{"test":"node --import tsx/esm test/index.test.ts","build":"tsc","benchmark":"node --import tsx/esm test/benchmark.ts","prepublishOnly":"npm run build"},"_npmUser":{"name":"baptistejamin","email":"baptistejamin@gmail.com"},"repository":{"url":"git+https://github.com/crisp-oss/farmhash-js.git","type":"git"},"_npmVersion":"11.6.1","description":"Pure JavaScript implementation of Google's FarmHash - compatible with farmhash v3.x and v5.x","directories":{},"_nodeVersion":"24.11.0","_hasShrinkwrap":false,"devDependencies":{"tsx":"4.21.0","farmhash":"3.3.1","typescript":"5.9.3","@types/node":"25.5.0","farmhash-modern":"npm:farmhash@5.0.0"},"_npmOperationalInternal":{"tmp":"tmp/farmhashjs_1.0.1_1775032940170_0.09397867800382187","host":"s3://npm-registry-packages-npm-production"}}},"time":{"created":"2026-04-01T07:24:54.974Z","modified":"2026-04-01T18:09:29.292Z","1.0.0":"2026-04-01T07:24:55.113Z","1.0.1":"2026-04-01T08:42:20.347Z"},"bugs":{"url":"https://github.com/crisp-oss/farmhash-js/issues"},"author":{"name":"Crisp IM SAS"},"license":"Apache-2.0","homepage":"https://github.com/crisp-oss/farmhash-js#readme","keywords":["farmhash","hash","fingerprint","hash64","hash32","cityhash","murmurhash","google"],"repository":{"url":"git+https://github.com/crisp-oss/farmhash-js.git","type":"git"},"description":"Pure JavaScript implementation of Google's FarmHash - compatible with farmhash v3.x and v5.x","maintainers":[{"email":"valerian@valeriansaliou.name","name":"valerian.saliou"},{"email":"baptistejamin@gmail.com","name":"baptistejamin"},{"email":"dev@crisp.chat","name":"crisp-dev"}],"readme":"# farmhashjs\n\n[![Test and Build](https://github.com/crisp-oss/farmhash-js/actions/workflows/test.yml/badge.svg)](https://github.com/crisp-oss/farmhash-js/actions/workflows/test.yml)\n[![NPM](https://img.shields.io/npm/v/farmhashjs.svg)](https://www.npmjs.com/package/farmhashjs)\n[![Downloads](https://img.shields.io/npm/dm/farmhashjs.svg)](https://www.npmjs.com/package/farmhashjs)\n\n**Pure JavaScript implementation of Google's [FarmHash](https://github.com/google/farmhash) algorithm. No native dependencies, works in Node.js and browsers.**\n\n**😘 Maintainer**: [@baptistejamin](https://github.com/baptistejamin)\n\n## Why?\n\nThe native `farmhash` npm package requires C++ compilation, which can be problematic:\n- Fails on some platforms (Windows, Alpine Linux, etc.)\n- Requires node-gyp and build tools\n- Doesn't work in browsers or edge runtimes\n\n`farmhashjs` provides the same hash outputs with zero native dependencies.\n\n## Installation\n\n```bash\nnpm install farmhashjs\n```\n\n## Usage\n\n```javascript\nimport { \n  fingerprint64, fingerprint32,\n  legacyHash64_arm, legacyHash64_x86,\n  legacyHash32_arm, legacyHash32_x86\n} from 'farmhashjs';\n\n// Modern stable fingerprints (recommended - same on all platforms)\nfingerprint64('hello world');  // \"6381520714923946011\"\nfingerprint32('hello world');  // 430397466\n\n// Legacy hashes (compatible with farmhash@3.3.1)\n// Use _arm or _x86 suffix based on your target platform\nlegacyHash64_arm('hello world');  // \"16022978042064026561\"\nlegacyHash64_x86('hello world');  // \"16022978042064026561\" (same for <512 bytes)\n\nlegacyHash32_arm('hello world');  // 3314386015\nlegacyHash32_x86('hello world');  // 1955099599\n```\n\n## API\n\n### Modern Functions (Stable Fingerprints)\n\nThese produce stable hashes guaranteed to be consistent across all platforms and versions.\n\n| Function | Returns | Description |\n|----------|---------|-------------|\n| `fingerprint64(input)` | `string` | 64-bit hash as decimal string |\n| `fingerprint64BigInt(input)` | `bigint` | 64-bit hash as BigInt |\n| `fingerprint32(input)` | `number` | 32-bit hash as number |\n\n### Legacy Functions (farmhash v3.x Compatible)\n\nThese are compatible with `farmhash@3.3.1` which was compiled with `FARMHASH_DEBUG=1`.\n\n**Important:** The native `farmhash@3.3.1` produces different outputs on ARM64 vs x86_64 architectures. Choose the `_arm` or `_x86` variant based on your target platform.\n\n| Function | Returns | Description |\n|----------|---------|-------------|\n| `legacyHash64_arm(input)` | `string` | 64-bit hash (ARM64) |\n| `legacyHash64_x86(input)` | `string` | 64-bit hash (x86_64, <512 bytes) |\n| `legacyHash64BigInt_arm(input)` | `bigint` | 64-bit hash as BigInt (ARM64) |\n| `legacyHash64BigInt_x86(input)` | `bigint` | 64-bit hash as BigInt (x86_64, <512 bytes) |\n| `legacyHash32_arm(input)` | `number` | 32-bit hash (ARM64) |\n| `legacyHash32_x86(input)` | `number` | 32-bit hash (x86_64, <512 bytes) |\n\n**Notes:**\n- For `hash64`: ARM64 and x86_64 produce the same output for strings <512 bytes. For ≥512 bytes, different algorithms are used.\n- For `hash32`: ARM64 and x86_64 produce different outputs for ALL strings (different algorithms).\n- The x86_64 SIMD algorithm (farmhashte) is fully implemented in pure JavaScript.\n\n### Aliases\n\n```javascript\nimport { hash64, hash32 } from 'farmhashjs';\n\n// hash64 = fingerprint64\n// hash32 = fingerprint32\n```\n\n## Compatibility\n\nTested against native implementations:\n\n| Function | Compared Against |\n|----------|------------------|\n| `fingerprint64` | `farmhash@5.0.0` fingerprint64 |\n| `fingerprint32` | `farmhash@5.0.0` fingerprint32 |\n| `legacyHash64_arm` | `farmhash@3.3.1` hash64 on ARM64 |\n| `legacyHash64_x86` | `farmhash@3.3.1` hash64 on x86_64 (<512 bytes) |\n| `legacyHash32_arm` | `farmhash@3.3.1` hash32 on ARM64 |\n| `legacyHash32_x86` | `farmhash@3.3.1` hash32 on x86_64 (<512 bytes) |\n\n## Performance\n\nBenchmarked on Apple M1:\n\n| Function | 44 bytes | 500 bytes | 5 KB |\n|----------|----------|-----------|------|\n| `fingerprint32` | 251 ns/op | 903 ns/op | 9 µs/op |\n| `fingerprint64` | 843 ns/op | 7 µs/op | 65 µs/op |\n| `legacyHash32_arm` | 302 ns/op | 974 ns/op | 9 µs/op |\n| `legacyHash64_arm` | 1.1 µs/op | 6.8 µs/op | 58 µs/op |\n\n32-bit functions are faster because they use native `number` operations. 64-bit functions use `BigInt` which has more overhead.\n\nFor comparison, native C++ (`farmhash@5.0.0`) is ~2-10x faster depending on input size.\n\n## When to Use\n\n**Use `farmhashjs` when:**\n- You need cross-platform compatibility\n- You're running in browsers, Cloudflare Workers, or edge runtimes\n- You can't compile native modules\n- You're hashing moderate volumes (< 100K hashes/second)\n\n**Use native `farmhash` when:**\n- Maximum performance is critical\n- You're in a Node.js environment that supports native modules\n- You're hashing millions of strings per second\n\n## License\n\nApache-2.0\n\nThis is a port of Google's FarmHash. Original FarmHash is Copyright 2014 Google Inc.\n","readmeFilename":"README.md"}