{"_id":"fnv1a-64","_rev":"3-fd6664865160b725be528524b166aa2e","name":"fnv1a-64","dist-tags":{"latest":"0.1.2"},"versions":{"0.0.0":{"name":"fnv1a-64","version":"0.0.0","author":{"name":"Daniel Roe","email":"daniel@roe.dev"},"_id":"fnv1a-64@0.0.0","maintainers":[{"name":"danielroe","email":"daniel@roe.dev"}],"dist":{"shasum":"0082f3b74315a37594e40d4a25282dc94e5c8e48","tarball":"https://registry.npmjs.org/fnv1a-64/-/fnv1a-64-0.0.0.tgz","fileCount":2,"integrity":"sha512-Lx2YI6UkFlAOrmG/jEpdkjZFvGgwc2hMHhHMrjJTmvtCdU03y6pV5xAb7/v3vimb+rzsT+VSir7bIv/vobNCNA==","signatures":[{"sig":"MEQCIEaKIgMTuVyHm5/zFw14Bcn3rnJrJgesISPD6OPq5vZpAiA2eq2fhdqsxPDwC5KOVasfL6W++qXpBRV9qYO/mSTQcw==","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":119},"gitHead":"738cca0bf06ba0e95a87271b86342ccfb78122b7","_npmUser":{"name":"danielroe","email":"daniel@roe.dev"},"_npmVersion":"11.15.0","directories":{},"_nodeVersion":"24.15.0","_hasShrinkwrap":false,"_npmOperationalInternal":{"tmp":"tmp/fnv1a-64_0.0.0_1784110812952_0.8375756782258845","host":"s3://npm-registry-packages-npm-production"}},"0.1.1":{"name":"fnv1a-64","version":"0.1.1","keywords":["fnv","fnv1a","fnv-1a","hash","64-bit","non-cryptographic"],"license":"MIT","_id":"fnv1a-64@0.1.1","maintainers":[{"name":"danielroe","email":"daniel@roe.dev"}],"homepage":"https://github.com/danielroe/fnv1a-64#readme","bugs":{"url":"https://github.com/danielroe/fnv1a-64/issues"},"dist":{"shasum":"99ffcf8df3783104cb288ce1ac2964e3e64883a8","tarball":"https://registry.npmjs.org/fnv1a-64/-/fnv1a-64-0.1.1.tgz","fileCount":5,"integrity":"sha512-qMpkqWyaiNxwYG7Dt40Bxtp2wV6KW/1woXVJOEvR1KA2ffsZf8pyvlNwJgFHha3teh8iC3d4arvrJ0qTcU445A==","signatures":[{"sig":"MEUCIFn+GtOriqIX+glnIVJoicT/0uKzBvyL/NWoyCkIQkarAiEAu1fGI4yJLK/yoFWx9m+Dk773Rw7u96XlGAAWJoclZbo=","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"attestations":{"url":"https://registry.npmjs.org/-/npm/v1/attestations/fnv1a-64@0.1.1","provenance":{"predicateType":"https://slsa.dev/provenance/v1"}},"unpackedSize":12279},"type":"module","_from":"file:/home/runner/work/_temp/uppt-tarballs/fnv1a-64-0.1.1.tgz","types":"./dist/index.d.mts","exports":{".":"./dist/index.mjs","./package.json":"./package.json"},"scripts":{"dev":"vitest dev","lint":"oxlint --type-aware","test":"pnpm test:unit && pnpm test:types","bench":"node bench.mjs","build":"tsdown","test:knip":"knip","test:unit":"vitest","collisions":"node collisions.mjs","test:types":"tsc --noEmit","test:versions":"installed-check -d --no-workspaces"},"_npmUser":{"name":"GitHub Actions","email":"npm-oidc-no-reply@github.com","approver":{"name":"danielroe","email":"daniel@roe.dev"},"trustedPublisher":{"id":"github","oidcConfigId":"oidc:dc44b2c6-3ee7-493e-b6db-20eaa236530f"}},"_resolved":"/home/runner/work/_temp/uppt-tarballs/fnv1a-64-0.1.1.tgz","_integrity":"sha512-qMpkqWyaiNxwYG7Dt40Bxtp2wV6KW/1woXVJOEvR1KA2ffsZf8pyvlNwJgFHha3teh8iC3d4arvrJ0qTcU445A==","repository":{"url":"git+https://github.com/danielroe/fnv1a-64.git","type":"git"},"_npmVersion":"12.0.1","description":"Tiny, fast, dependency-free 64-bit FNV-1a string hash for Node and the browser","directories":{},"nano-staged":{"*.{js,ts,mjs,cjs,json,.*rc}":["npx oxlint --type-aware --fix"]},"sideEffects":false,"_nodeVersion":"24.18.0","typesVersions":{"*":{"*":["./dist/index.d.mts"]}},"_hasShrinkwrap":false,"devDependencies":{"knip":"6.26.0","mitata":"^1.0.34","oxlint":"1.74.0","tsdown":"0.22.7","vitest":"4.1.10","fnv-lite":"^1.2.0","fnv-plus":"^1.3.1","xxhashjs":"^0.2.2","murmurhash":"^2.0.1","typescript":"7.0.2","@types/node":"26.1.1","nano-staged":"1.0.2","installed-check":"10.0.1","oxlint-tsgolint":"0.24.0","simple-git-hooks":"2.13.1","@sindresorhus/fnv1a":"^3.1.0","@vitest/coverage-v8":"4.1.10"},"simple-git-hooks":{"pre-commit":"npx nano-staged"},"_npmOperationalInternal":{"tmp":"tmp/fnv1a-64_0.1.1_1784114411493_0.4019815560072202","host":"s3://npm-registry-packages-npm-production"}},"0.1.2":{"_id":"fnv1a-64@0.1.2","bugs":{"url":"https://github.com/danielroe/fnv1a-64/issues"},"dist":{"shasum":"1cca3d160c92c0d8e5b3df3a9d8e2f71cbb7b2e8","tarball":"https://registry.npmjs.org/fnv1a-64/-/fnv1a-64-0.1.2.tgz","integrity":"sha512-mJbcILTPybAR1jdOwt/lVv8N2cffeJFFP+gVbSAwLEx1ujXH27RpPd8Rokec/KX9c76UYIB6Co+H4lQzxPnJfA==","fileCount":5,"unpackedSize":13343,"attestations":{"url":"https://registry.npmjs.org/-/npm/v1/attestations/fnv1a-64@0.1.2","provenance":{"predicateType":"https://slsa.dev/provenance/v1"}},"signatures":[{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEYCIQDNBwo9QibzNlZcI6NqRHJl7KB3koiDE9eWy5dnec/AHgIhAKMCp56jIgNhQswRRvATWtc+ArfuCagAOvW7vCS8ccXj"}]},"name":"fnv1a-64","type":"module","_from":"file:/home/runner/work/_temp/uppt-tarballs/fnv1a-64-0.1.2.tgz","types":"./dist/index.d.mts","exports":{".":"./dist/index.mjs","./package.json":"./package.json"},"license":"MIT","scripts":{"dev":"vitest dev","lint":"oxlint --type-aware","test":"pnpm test:unit && pnpm test:types","bench":"node bench.mjs","build":"tsdown","test:knip":"knip","test:unit":"vitest","collisions":"node collisions.mjs","test:types":"tsc --noEmit","test:versions":"installed-check -d --no-workspaces"},"version":"0.1.2","_npmUser":{"name":"GitHub Actions","email":"npm-oidc-no-reply@github.com","trustedPublisher":{"id":"github","oidcConfigId":"oidc:dc44b2c6-3ee7-493e-b6db-20eaa236530f"},"approver":{"name":"danielroe","email":"daniel@roe.dev"}},"homepage":"https://github.com/danielroe/fnv1a-64#readme","keywords":["fnv","fnv1a","fnv-1a","hash","64-bit","non-cryptographic"],"_resolved":"/home/runner/work/_temp/uppt-tarballs/fnv1a-64-0.1.2.tgz","_integrity":"sha512-mJbcILTPybAR1jdOwt/lVv8N2cffeJFFP+gVbSAwLEx1ujXH27RpPd8Rokec/KX9c76UYIB6Co+H4lQzxPnJfA==","repository":{"url":"git+https://github.com/danielroe/fnv1a-64.git","type":"git"},"_npmVersion":"12.0.1","description":"Tiny, fast, dependency-free 64-bit FNV-1a string hash for Node and the browser","directories":{},"maintainers":[{"name":"danielroe","email":"daniel@roe.dev"}],"nano-staged":{"*.{js,ts,mjs,cjs,json,.*rc}":["npx oxlint --type-aware --fix"]},"sideEffects":false,"_nodeVersion":"24.18.0","typesVersions":{"*":{"*":["./dist/index.d.mts"]}},"devDependencies":{"knip":"6.26.0","mitata":"^1.0.34","oxlint":"1.74.0","tsdown":"0.22.7","vitest":"4.1.10","fnv1a52":"^1.0.0","fnv-lite":"^1.2.0","fnv-plus":"^1.3.1","xxhashjs":"^0.2.2","murmurhash":"^2.0.1","typescript":"7.0.2","@types/node":"26.1.1","nano-staged":"1.0.2","installed-check":"10.0.1","oxlint-tsgolint":"0.24.0","simple-git-hooks":"2.13.1","@sindresorhus/fnv1a":"^3.1.0","@vitest/coverage-v8":"4.1.10"},"simple-git-hooks":{"pre-commit":"npx nano-staged"},"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/fnv1a-64_0.1.2_1785186977147_0.6885248140814959"},"_hasShrinkwrap":false}},"time":{"created":"2026-07-15T10:20:12.747Z","modified":"2026-07-27T21:16:17.637Z","0.0.0":"2026-07-15T10:20:13.103Z","0.1.1":"2026-07-15T11:20:11.577Z","0.1.2":"2026-07-27T21:16:17.232Z"},"bugs":{"url":"https://github.com/danielroe/fnv1a-64/issues"},"license":"MIT","homepage":"https://github.com/danielroe/fnv1a-64#readme","keywords":["fnv","fnv1a","fnv-1a","hash","64-bit","non-cryptographic"],"repository":{"url":"git+https://github.com/danielroe/fnv1a-64.git","type":"git"},"description":"Tiny, fast, dependency-free 64-bit FNV-1a string hash for Node and the browser","maintainers":[{"name":"danielroe","email":"daniel@roe.dev"}],"readme":"# fnv1a-64\n\n[![npm version][npm-version-src]][npm-version-href]\n[![npm downloads][npm-downloads-src]][npm-downloads-href]\n[![Github Actions][github-actions-src]][github-actions-href]\n[![Codecov][codecov-src]][codecov-href]\n\n> Tiny, fast, dependency-free 64-bit [FNV-1a](http://www.isthe.com/chongo/tech/comp/fnv/) string hash for Node and the browser.\n\nThe core computes a true 64-bit hash in two 32-bit lanes with plain JS numbers. It's ~320B gzipped (minified) and hashes a short key in ~36ns.\n\n> [!IMPORTANT]\n>\n> FNV-1a is a fast, **non-cryptographic** hash. It's useful for hash tables, cache keys, checksums, and bucketing, but do not use it for anything security-sensitive: it is not collision-resistant against an adversary and offers no preimage resistance.\n\n## Why\n\nI created this for [Nuxt](https://github.com/nuxt/nuxt) due to particular constraints (fast, small, browser-use, no collisions), but you should consider using one of these other packages if you don't have the same constraints I did:\n\n| Package | Width | Gzip | Notes |\n| --- | --- | --- | --- |\n| `fnv1a`, `object-code` | 32-bit | tiny | collides at ~50k distinct keys |\n| [`fnv1a52`](https://github.com/SukkaW/fnv1a52) | 52-bit | tiny | faster than this package; fits in a JS `number` |\n| `@sindresorhus/fnv1a` | 64-bit | ~1KB | BigInt, ~20x slower |\n| `fnv-lite` | 128-bit | ~1.4KB | byte arrays, ~40x slower |\n| `fnv-plus` | multi | ~9KB | _excellent_ package, but contains lots of utilities |\n| `fnv-hash` | 64-bit | native | can't run in the browser |\n\n## Usage\n\n```sh\nnpm install fnv1a-64\n```\n\n```js\nimport { fnv1a64, fnv1a64Base36, fnv1a64BigInt, fnv1a64Hex } from 'fnv1a-64'\n\nfnv1a64Hex('hello world') // => '779a65e7023cd2e7'  (16-char zero-padded hex)\nfnv1a64Base36('hello world') // => '1th7cxzlyc0dj'  (shortest, good for cache keys)\nfnv1a64BigInt('hello world') // => 8618312879776256743n\nfnv1a64('hello world') // => { high: 2006607335, low: 37540583 }  (fast core, no BigInt)\n```\n\n- **`fnv1a64Hex`** and **`fnv1a64Base36`** are what you usually want as a map or cache key.\n- **`fnv1a64`** returns the raw 32-bit lanes and is the fastest path if you never need a string.\n- **`fnv1a64BigInt`** composes the lanes into a `bigint` when you want a single comparable number.\n\nAll outputs are deterministic: the same input always produces the same result. Hex is always exactly 16 characters; base36 length varies with the value but is stable per value.\n\n## Non-ASCII usage\n\nThe hash iterates `str.charCodeAt(i)`, so it hashes UTF-16 code units rather than UTF-8 bytes. For **ASCII input this is bit-for-bit identical to a canonical FNV-1a-64**. For non-ASCII (accents, CJK, emoji) the output is stable and collision-resistant but will **not** match an FNV-1a-64 computed over the UTF-8 encoding of the same string.\n\nIf you need to interoperate with a hash produced elsewhere over UTF-8 bytes, encode first:\n\n```js\nconst bytes = new TextEncoder().encode(str)\n// then hash the bytes with a UTF-8-aware FNV-1a-64 implementation\n```\n\n## Benchmark\n\nRun `pnpm bench` (uses [mitata](https://github.com/evanwashere/mitata)). Indicative numbers on Node 22 (Apple silicon), lower is better:\n\n| | width | short key | 1 KB string |\n| --- | --- | --- | --- |\n| `fnv1a-64` | 64 | **~25 ns** | ~2.0 µs |\n| `fnv1a-64` (hex) | 64 | ~49 ns | ~1.7 µs |\n| `fnv1a-64` (base 36) | 64 | ~87 ns | ~1.8 µs |\n| `fnv1a52` | 52 | **~24 ns** | ~1.9 µs |\n| `fnv1a52` (hex) | 52 | ~43 ns | ~2.0 µs |\n| `fnv1a52` (base 36) | 52 | ~64 ns | ~1.7 µs |\n| `fnv-plus` `fast1a64` | 64 | ~62 ns | ~1.7 µs |\n| `murmurhash` v3 | 32 | ~332 ns | **~1.5 µs** |\n| `@sindresorhus/fnv1a` | 64 | ~699 ns | ~28 µs |\n| `fnv-lite` `hex` | 128 | ~5.4 µs | ~296 µs |\n| `xxhashjs` `h64` | 64 | ~31 µs | ~57 µs |\n\nThe `fnv1a-64` core is the fastest 64-bit option on short keys (our main use in Nuxt), and hex formatting costs ~25 ns on top of it.\n`fnv1a52` matches it on short keys and needs no `BigInt` or lane pair, at the cost of 12 bits of hash space; pick it if 52 bits is enough for you.\nOn 1 KB inputs the FNV implementations are all within noise of each other.\n`fnv-plus` is competitive but ships ~9 KB gzipped for a whole multi-width toolkit rather than one function. This is less relevant if you're bundling or sharing the dependency.\n`murmurhash` is fastest on long inputs but is 32-bit, so it collides.\n`fnv-lite` and `xxhashjs` pay a large constant cost for their byte-array / `cuint` internals.\n\n## 💻 Development\n\n- Clone this repository\n- Enable [Corepack](https://github.com/nodejs/corepack) using `corepack enable`\n- Install dependencies using `pnpm install`\n- Run interactive tests using `pnpm dev`\n\n## License\n\nMade with ❤️\n\nPublished under [MIT License](./LICENCE).\n\n<!-- Badges -->\n\n[npm-version-src]: https://npmx.dev/api/registry/badge/version/fnv1a-64\n[npm-version-href]: https://npmx.dev/package/fnv1a-64\n[npm-downloads-src]: https://npmx.dev/api/registry/badge/downloads/fnv1a-64\n[npm-downloads-href]: https://npm.chart.dev/fnv1a-64\n[github-actions-src]: https://img.shields.io/github/actions/workflow/status/danielroe/fnv1a-64/ci.yml?branch=main&style=flat-square\n[github-actions-href]: https://github.com/danielroe/fnv1a-64/actions?query=workflow%3Aci\n[codecov-src]: https://img.shields.io/codecov/c/gh/danielroe/fnv1a-64/main?style=flat-square\n[codecov-href]: https://codecov.io/gh/danielroe/fnv1a-64\n","readmeFilename":"README.md"}