{"_id":"@sindresorhus/fnv1a","_rev":"4658090","name":"@sindresorhus/fnv1a","description":"FNV-1a non-cryptographic hash function","dist-tags":{"latest":"3.1.0"},"maintainers":[{"name":"sindresorhus","email":""}],"time":{"modified":"2026-04-10T21:24:56.000Z","created":"2018-01-07T01:21:52.044Z","3.1.0":"2023-11-16T11:56:38.188Z","3.0.0":"2021-08-22T20:41:40.315Z","2.0.1":"2020-05-17T06:56:54.600Z","2.0.0":"2019-11-18T06:42:05.816Z","1.2.0":"2019-03-31T12:21:31.822Z","1.1.0":"2019-03-18T07:33:59.453Z","1.0.0":"2018-01-07T01:21:52.044Z"},"users":{},"author":{"name":"Sindre Sorhus","email":"sindresorhus@gmail.com","url":"https://sindresorhus.com"},"repository":{"type":"git","url":"git+https://github.com/sindresorhus/fnv1a.git"},"versions":{"3.1.0":{"name":"@sindresorhus/fnv1a","version":"3.1.0","description":"FNV-1a non-cryptographic hash function","license":"MIT","repository":{"type":"git","url":"git+https://github.com/sindresorhus/fnv1a.git"},"funding":"https://github.com/sponsors/sindresorhus","author":{"name":"Sindre Sorhus","email":"sindresorhus@gmail.com","url":"https://sindresorhus.com"},"type":"module","exports":"./index.js","types":"./index.d.ts","sideEffects":false,"engines":{"node":"^12.20.0 || ^14.13.1 || >=16.0.0"},"scripts":{"test":"xo && ava && tsd"},"keywords":["fnv1a","fnv-1a","fnv1","fnv-1","fnv","algorithm","hash","hashing","string","function","fowler–noll–vo","fowler","noll","vo","unicode","bigint"],"devDependencies":{"ava":"3.15.0","tsd":"0.17.0","xo":"0.44.0"},"gitHead":"ebe1ce3d2b2d852abaf152e54310b32bd89136f0","bugs":{"url":"https://github.com/sindresorhus/fnv1a/issues"},"homepage":"https://github.com/sindresorhus/fnv1a#readme","_id":"@sindresorhus/fnv1a@3.1.0","_nodeVersion":"18.18.2","_npmVersion":"9.2.0","dist":{"shasum":"f8e46597298f6fd4c12dc901cdd4e73beb4d24fa","size":3860,"noattachment":false,"key":"/@sindresorhus/fnv1a/-/@sindresorhus/fnv1a-3.1.0.tgz","tarball":"http://registry.cnpm.dingdandao.com/@sindresorhus/fnv1a/download/@sindresorhus/fnv1a-3.1.0.tgz"},"_npmUser":{"name":"sindresorhus","email":"sindresorhus@gmail.com"},"directories":{},"maintainers":[{"name":"sindresorhus","email":""}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/fnv1a_3.1.0_1700135797917_0.2561458522505369"},"_hasShrinkwrap":false,"_cnpmcore_publish_time":"2023-11-16T11:56:38.188Z","publish_time":1700135798188,"_source_registry_name":"default","_cnpm_publish_time":1700135798188},"3.0.0":{"name":"@sindresorhus/fnv1a","version":"3.0.0","description":"FNV-1a non-cryptographic hash function","license":"MIT","repository":{"type":"git","url":"git+https://github.com/sindresorhus/fnv1a.git"},"funding":"https://github.com/sponsors/sindresorhus","author":{"name":"Sindre Sorhus","email":"sindresorhus@gmail.com","url":"https://sindresorhus.com"},"type":"module","exports":"./index.js","engines":{"node":"^12.20.0 || ^14.13.1 || >=16.0.0"},"scripts":{"test":"xo && ava && tsd"},"keywords":["fnv1a","fnv-1a","fnv1","fnv-1","fnv","algorithm","hash","hashing","string","function","fowler–noll–vo","fowler","noll","vo","unicode","bigint"],"devDependencies":{"ava":"3.15.0","tsd":"0.17.0","xo":"0.44.0"},"gitHead":"053a8cb5a0f99212e71acb73a47823f26081b6e9","bugs":{"url":"https://github.com/sindresorhus/fnv1a/issues"},"homepage":"https://github.com/sindresorhus/fnv1a#readme","_id":"@sindresorhus/fnv1a@3.0.0","_nodeVersion":"16.6.2","_npmVersion":"7.20.3","dist":{"shasum":"e8ce2e7c7738ec8c354867d38e3bfcde622b87ca","size":3338,"noattachment":false,"key":"/@sindresorhus/fnv1a/-/@sindresorhus/fnv1a-3.0.0.tgz","tarball":"http://registry.cnpm.dingdandao.com/@sindresorhus/fnv1a/download/@sindresorhus/fnv1a-3.0.0.tgz"},"_npmUser":{"name":"sindresorhus","email":"sindresorhus@gmail.com"},"directories":{},"maintainers":[{"name":"sindresorhus","email":""}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/fnv1a_3.0.0_1629664900158_0.12160131473192415"},"_hasShrinkwrap":false,"publish_time":1629664900315,"_cnpm_publish_time":1629664900315,"_cnpmcore_publish_time":"2021-12-16T23:41:46.333Z"},"2.0.1":{"name":"@sindresorhus/fnv1a","version":"2.0.1","description":"FNV-1a non-cryptographic hash function","license":"MIT","repository":{"type":"git","url":"git+https://github.com/sindresorhus/fnv1a.git"},"author":{"name":"Sindre Sorhus","email":"sindresorhus@gmail.com","url":"sindresorhus.com"},"engines":{"node":">=10"},"scripts":{"test":"xo && ava && tsd"},"keywords":["fnv1a","fnv-1a","fnv1","fnv-1","fnv","algorithm","hash","hashing","string","function","fowler–noll–vo","fowler","noll","vo","unicode","bigint"],"devDependencies":{"ava":"2.4.0","tsd":"0.11.0","xo":"0.25.3"},"xo":{"globals":["BigInt"]},"gitHead":"ddeec8229c8576cda8f3b04e5596bceba7f646c4","bugs":{"url":"https://github.com/sindresorhus/fnv1a/issues"},"homepage":"https://github.com/sindresorhus/fnv1a#readme","_id":"@sindresorhus/fnv1a@2.0.1","_nodeVersion":"10.20.1","_npmVersion":"6.14.4","_npmUser":{"name":"sindresorhus","email":"sindresorhus@gmail.com"},"dist":{"shasum":"2aefdfa7eb5b7f29a7936978218e986c70c603fc","size":3391,"noattachment":false,"key":"/@sindresorhus/fnv1a/-/@sindresorhus/fnv1a-2.0.1.tgz","tarball":"http://registry.cnpm.dingdandao.com/@sindresorhus/fnv1a/download/@sindresorhus/fnv1a-2.0.1.tgz"},"maintainers":[{"name":"sindresorhus","email":""}],"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/fnv1a_2.0.1_1589698614413_0.6466607395424904"},"_hasShrinkwrap":false,"publish_time":1589698614600,"_cnpm_publish_time":1589698614600,"_cnpmcore_publish_time":"2021-12-16T23:41:46.580Z"},"2.0.0":{"name":"@sindresorhus/fnv1a","version":"2.0.0","description":"FNV-1a non-cryptographic hash function","license":"MIT","repository":{"type":"git","url":"git+https://github.com/sindresorhus/fnv1a.git"},"author":{"name":"Sindre Sorhus","email":"sindresorhus@gmail.com","url":"sindresorhus.com"},"engines":{"node":">=10"},"scripts":{"test":"xo && ava && tsd"},"keywords":["fnv1a","fnv-1a","fnv1","fnv-1","fnv","algorithm","hash","hashing","string","function","fowler–noll–vo","fowler","noll","vo","unicode","bigint"],"devDependencies":{"ava":"2.4.0","tsd":"0.11.0","xo":"0.25.3"},"xo":{"globals":["BigInt"]},"gitHead":"91c50f0cf2647c5a343483f0ced4cfdf6b192534","bugs":{"url":"https://github.com/sindresorhus/fnv1a/issues"},"homepage":"https://github.com/sindresorhus/fnv1a#readme","_id":"@sindresorhus/fnv1a@2.0.0","_nodeVersion":"10.17.0","_npmVersion":"6.11.3","_npmUser":{"name":"sindresorhus","email":"sindresorhus@gmail.com"},"dist":{"shasum":"2c8c77f887eeb9762dc5fa6614215671085a7a3b","size":3392,"noattachment":false,"key":"/@sindresorhus/fnv1a/-/@sindresorhus/fnv1a-2.0.0.tgz","tarball":"http://registry.cnpm.dingdandao.com/@sindresorhus/fnv1a/download/@sindresorhus/fnv1a-2.0.0.tgz"},"maintainers":[{"name":"sindresorhus","email":""}],"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/fnv1a_2.0.0_1574059325606_0.3689381281129338"},"_hasShrinkwrap":false,"publish_time":1574059325816,"_cnpm_publish_time":1574059325816,"_cnpmcore_publish_time":"2021-12-16T23:41:46.778Z"},"1.2.0":{"name":"@sindresorhus/fnv1a","version":"1.2.0","description":"FNV-1a non-cryptographic hash function","license":"MIT","repository":{"type":"git","url":"git+https://github.com/sindresorhus/fnv1a.git"},"author":{"name":"Sindre Sorhus","email":"sindresorhus@gmail.com","url":"sindresorhus.com"},"engines":{"node":">=6"},"scripts":{"test":"xo && ava && tsd"},"keywords":["fnv1a","fnv-1a","fnv1","fnv-1","fnv","algorithm","hash","hashing","string","function","fowler–noll–vo","fowler","noll","vo"],"devDependencies":{"ava":"^1.4.1","tsd":"^0.7.1","xo":"^0.24.0"},"gitHead":"7a72892dc41050c89e229ef0a07cdb239b095d0b","bugs":{"url":"https://github.com/sindresorhus/fnv1a/issues"},"homepage":"https://github.com/sindresorhus/fnv1a#readme","_id":"@sindresorhus/fnv1a@1.2.0","_nodeVersion":"8.15.0","_npmVersion":"6.9.0","_npmUser":{"name":"sindresorhus","email":"sindresorhus@gmail.com"},"dist":{"shasum":"d554da64c406f3b62ad06dfce9efd537a4a55de4","size":2197,"noattachment":false,"key":"/@sindresorhus/fnv1a/-/@sindresorhus/fnv1a-1.2.0.tgz","tarball":"http://registry.cnpm.dingdandao.com/@sindresorhus/fnv1a/download/@sindresorhus/fnv1a-1.2.0.tgz"},"maintainers":[{"name":"sindresorhus","email":""}],"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/fnv1a_1.2.0_1554034891692_0.9441434239692896"},"_hasShrinkwrap":false,"publish_time":1554034891822,"_cnpm_publish_time":1554034891822,"_cnpmcore_publish_time":"2021-12-16T23:41:47.063Z"},"1.1.0":{"name":"@sindresorhus/fnv1a","version":"1.1.0","description":"FNV-1a non-cryptographic hash function","license":"MIT","repository":{"type":"git","url":"git+https://github.com/sindresorhus/fnv1a.git"},"author":{"name":"Sindre Sorhus","email":"sindresorhus@gmail.com","url":"sindresorhus.com"},"engines":{"node":">=6"},"scripts":{"test":"xo && ava && tsd-check"},"keywords":["fnv1a","fnv-1a","fnv1","fnv-1","fnv","algorithm","hash","hashing","string","function","fowler–noll–vo","fowler","noll","vo"],"devDependencies":{"ava":"^1.3.1","tsd-check":"^0.5.0","xo":"^0.24.0"},"gitHead":"c2236080ed4ef94c5911a0d6646bc542b42e48c0","bugs":{"url":"https://github.com/sindresorhus/fnv1a/issues"},"homepage":"https://github.com/sindresorhus/fnv1a#readme","_id":"@sindresorhus/fnv1a@1.1.0","_nodeVersion":"8.15.0","_npmVersion":"6.9.0","_npmUser":{"name":"sindresorhus","email":"sindresorhus@gmail.com"},"dist":{"shasum":"a5cce7967382753ffd9c954619c287e24b365878","size":2087,"noattachment":false,"key":"/@sindresorhus/fnv1a/-/@sindresorhus/fnv1a-1.1.0.tgz","tarball":"http://registry.cnpm.dingdandao.com/@sindresorhus/fnv1a/download/@sindresorhus/fnv1a-1.1.0.tgz"},"maintainers":[{"name":"sindresorhus","email":""}],"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/fnv1a_1.1.0_1552894439348_0.710095838038409"},"_hasShrinkwrap":false,"publish_time":1552894439453,"_cnpm_publish_time":1552894439453,"_cnpmcore_publish_time":"2021-12-16T23:41:47.280Z"},"1.0.0":{"name":"@sindresorhus/fnv1a","version":"1.0.0","description":"FNV-1a non-cryptographic hash function","license":"MIT","repository":{"type":"git","url":"git+https://github.com/sindresorhus/fnv1a.git"},"author":{"name":"Sindre Sorhus","email":"sindresorhus@gmail.com","url":"sindresorhus.com"},"publishConfig":{"access":"public"},"engines":{"node":">=6"},"scripts":{"test":"xo && ava"},"files":["index.js"],"keywords":["fnv1a","fnv-1a","fnv1","fnv-1","fnv","algorithm","hash","hashing","string","function","fowler–noll–vo","fowler","noll","vo"],"devDependencies":{"ava":"*","xo":"*"},"gitHead":"15d98d072023101889e07b95ea567d942ecea537","bugs":{"url":"https://github.com/sindresorhus/fnv1a/issues"},"homepage":"https://github.com/sindresorhus/fnv1a#readme","_id":"@sindresorhus/fnv1a@1.0.0","_npmVersion":"5.5.1","_nodeVersion":"8.9.0","_npmUser":{"name":"sindresorhus","email":"sindresorhus@gmail.com"},"dist":{"shasum":"d419dd111b4d7fc3b87f97d86849bc23316149de","size":2007,"noattachment":false,"key":"/@sindresorhus/fnv1a/-/@sindresorhus/fnv1a-1.0.0.tgz","tarball":"http://registry.cnpm.dingdandao.com/@sindresorhus/fnv1a/download/@sindresorhus/fnv1a-1.0.0.tgz"},"maintainers":[{"name":"sindresorhus","email":""}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/fnv1a-1.0.0.tgz_1515288111087_0.8035861416719854"},"directories":{},"publish_time":1515288112044,"_hasShrinkwrap":false,"_cnpm_publish_time":1515288112044,"_cnpmcore_publish_time":"2021-12-16T23:41:47.482Z"}},"readme":"# fnv1a\n\n> [FNV-1a](https://en.wikipedia.org/wiki/Fowler%E2%80%93Noll%E2%80%93Vo_hash_function) non-cryptographic hash function\n\n[FNV-1a has outstanding distribution and collisions are rare.](https://softwareengineering.stackexchange.com/questions/49550/which-hashing-algorithm-is-best-for-uniqueness-and-speed/145633#145633)\n\nFNV hashes are designed to be fast while maintaining a low collision rate. The FNV speed allows one to quickly hash lots of data while maintaining a reasonable collision rate. The high dispersion of the FNV hashes makes them well suited for hashing nearly identical strings such as URLs, hostnames, filenames, text, IP addresses, etc.\n\n## Install\n\n```sh\nnpm install @sindresorhus/fnv1a\n```\n\n## Usage\n\n```js\nimport fnv1a from '@sindresorhus/fnv1a';\n\nfnv1a('????????', {size: 32});\n//=> 2868248295n\n\nfnv1a('????????', {size: 128});\n//=> 13487074350300261116944693128525960095n\n\nNumber(fnv1a('????????', {size: 32}));\n//=> 2868248295\n\nconst bytes = new Uint8Array([240, 159, 166, 132, 240, 159, 140, 136]);\nfnv1a(bytes, {size: 32});\n//=> 2868248295n\n```\n\n## API\n\n### fnv1a(value, options?)\n\nReturns the hash as a positive `BigInt`.\n\nIf you need it as a `number`, use `32` as `size` and wrap the return value in `Number(…)`.\n\n#### value\n\nType: `string | Uint8Array`\n\nA string or UTF-8 bytes.\n\n#### options\n\nType: `object`\n\n##### size\n\nType: `number`\\\nValues: `32 | 64 | 128 | 256 | 512 | 1024`\\\nDefault: `32`\n\nThe bit size of the hash.\n\n##### utf8Buffer\n\nType: `Uint8Array`\n\nA Uint8Array used to encode the string into UTF-8 bytes.\n\nThis array can be reused across calls to `fnv1a`. Doing so will improve performance because it avoids allocating a new Uint8Array when encoding the string.\n\nThe size of the array does not have to be large enugh to hold the entire string, but performance will be improved if it is.\n\nThis option is only used when `value` is a string.\n\n```js\nimport fnv1a from '@sindresorhus/fnv1a';\n\nconst utf8Buffer = new Uint8Array(100);\n\nfnv1a('????????', {size: 32, utf8Buffer});\n//=> 2868248295n\n```\n\n## Related\n\n- [djb2a](https://github.com/sindresorhus/djb2a) - DJB2a non-cryptographic hash function\n- [sdbm](https://github.com/sindresorhus/sdbm) - SDBM non-cryptographic hash function\n","_attachments":{},"homepage":"https://github.com/sindresorhus/fnv1a#readme","bugs":{"url":"https://github.com/sindresorhus/fnv1a/issues"},"license":"MIT"}