{"id":13583095,"url":"https://github.com/sindresorhus/fnv1a","last_synced_at":"2025-05-16T09:05:56.743Z","repository":{"id":55414443,"uuid":"116527475","full_name":"sindresorhus/fnv1a","owner":"sindresorhus","description":"FNV-1a non-cryptographic hash function","archived":false,"fork":false,"pushed_at":"2023-11-16T11:56:42.000Z","size":29,"stargazers_count":231,"open_issues_count":0,"forks_count":14,"subscribers_count":4,"default_branch":"main","last_synced_at":"2025-05-02T23:27:35.705Z","etag":null,"topics":["fnv","fnv-1a","fnv-algorithms","node-module","non-cryptographic-hash-functions","npm-package"],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/sindresorhus.png","metadata":{"files":{"readme":"readme.md","changelog":null,"contributing":null,"funding":null,"license":"license","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":".github/security.md","support":null,"governance":null},"funding":{"github":"sindresorhus","open_collective":"sindresorhus","custom":"https://sindresorhus.com/donate"}},"created_at":"2018-01-07T01:09:29.000Z","updated_at":"2025-05-02T06:24:09.000Z","dependencies_parsed_at":"2023-11-19T20:03:06.057Z","dependency_job_id":"e145be44-af4c-4745-b72c-06f826ba8ce4","html_url":"https://github.com/sindresorhus/fnv1a","commit_stats":{"total_commits":23,"total_committers":7,"mean_commits":"3.2857142857142856","dds":"0.30434782608695654","last_synced_commit":"ebe1ce3d2b2d852abaf152e54310b32bd89136f0"},"previous_names":[],"tags_count":7,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sindresorhus%2Ffnv1a","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sindresorhus%2Ffnv1a/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sindresorhus%2Ffnv1a/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sindresorhus%2Ffnv1a/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/sindresorhus","download_url":"https://codeload.github.com/sindresorhus/fnv1a/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":252848815,"owners_count":21813724,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["fnv","fnv-1a","fnv-algorithms","node-module","non-cryptographic-hash-functions","npm-package"],"created_at":"2024-08-01T15:03:15.149Z","updated_at":"2025-05-16T09:05:56.690Z","avatar_url":"https://github.com/sindresorhus.png","language":"JavaScript","funding_links":["https://github.com/sponsors/sindresorhus","https://opencollective.com/sindresorhus","https://sindresorhus.com/donate"],"categories":["JavaScript"],"sub_categories":[],"readme":"# fnv1a\n\n\u003e [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//=\u003e 2868248295n\n\nfnv1a('🦄🌈', {size: 128});\n//=\u003e 13487074350300261116944693128525960095n\n\nNumber(fnv1a('🦄🌈', {size: 32}));\n//=\u003e 2868248295\n\nconst bytes = new Uint8Array([240, 159, 166, 132, 240, 159, 140, 136]);\nfnv1a(bytes, {size: 32});\n//=\u003e 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//=\u003e 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","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsindresorhus%2Ffnv1a","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsindresorhus%2Ffnv1a","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsindresorhus%2Ffnv1a/lists"}