{"id":50334500,"url":"https://github.com/komed3/fastdict","last_synced_at":"2026-05-29T12:31:00.713Z","repository":{"id":346114219,"uuid":"1188555514","full_name":"komed3/fastdict","owner":"komed3","description":"Fast and efficient dictionary implementation with optimized hash functions","archived":false,"fork":false,"pushed_at":"2026-05-19T07:46:29.000Z","size":124,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2026-05-19T10:26:34.182Z","etag":null,"topics":["dictionary","fnv-1a","hash-functions","hashing","hashtable","map","murmur","npm-package","table"],"latest_commit_sha":null,"homepage":"https://npmjs.com/fastdict","language":"TypeScript","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/komed3.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":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2026-03-22T08:47:21.000Z","updated_at":"2026-05-19T07:46:26.000Z","dependencies_parsed_at":null,"dependency_job_id":null,"html_url":"https://github.com/komed3/fastdict","commit_stats":null,"previous_names":["komed3/hashtable","komed3/fastdict"],"tags_count":1,"template":false,"template_full_name":null,"purl":"pkg:github/komed3/fastdict","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/komed3%2Ffastdict","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/komed3%2Ffastdict/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/komed3%2Ffastdict/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/komed3%2Ffastdict/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/komed3","download_url":"https://codeload.github.com/komed3/fastdict/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/komed3%2Ffastdict/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":33652977,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-26T15:22:16.424Z","status":"online","status_checked_at":"2026-05-29T02:00:06.066Z","response_time":107,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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":["dictionary","fnv-1a","hash-functions","hashing","hashtable","map","murmur","npm-package","table"],"created_at":"2026-05-29T12:31:00.377Z","updated_at":"2026-05-29T12:31:00.696Z","avatar_url":"https://github.com/komed3.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# fastdict\n\nA fast and efficient dictionary implementation for caching and data storage with optimized hash functions, written in TypeScript.\n\n`fastdict` provides a high-performance `Dict` class with support for customizable hashing algorithms (including FNV-1a and MurmurHash3), seedable hashes, and FIFO-based eviction to manage memory usage efficiently.\n\nA third hash algorithm named `fasthash` is included, based on FNV-1a and the MurmurHash3 finalizer. This algorithm is optimized for performance.\n\n## Installation\n\nInstall via npm:\n\n```bash\nnpm install fastdict\n```\n\n## Quick usage\n\nCreate a new instance and manage your data:\n\n```ts\nimport { Dict } from 'fastdict';\n\n// initialize with default options (fasthash, max 10,000 items)\nconst dict = new Dict();\n\n// generate a unique key from string components\nconst key = dict.key( [ 'user', '123' ] );\n\nif ( key ) {\n\t// store data\n\tdict.set( key, { name: 'Max', role: 'admin' } );\n\n\t// retrieve data\n\tconst user = dict.get( key );\n\tconsole.log( user ); // { name: 'Max', role: 'admin' }\n\n\t// check existence\n\tconsole.log( dict.has( key ) ); // true\n\n\t// delete entry\n\tdict.delete( key );\n}\n```\n\n## API reference\n\n### Instantiate\n\n- `new Dict( options? )`  \n  Creates a new `Dict` instance with optional configuration.\n\n### Storage \u0026 Retrieval\n\n- `set\u003c T \u003e( key: string, entry: T, update: boolean = true ) : boolean`  \n  Stores an entry. If the dict is full and `fifo` is enabled, the oldest entry is removed. Returns `false` if `update` is false and key exists, or if dict is full and FIFO is disabled.\n- `get\u003c T \u003e( key: string ) : T | undefined`  \n  Retrieves the entry associated with the given key.\n- `has( key: string ) : boolean`  \n  Returns `true` if the key exists in the dict.\n- `delete( key: string ) : boolean`  \n  Removes an entry from the dict. Returns `true` if deleted.\n- `clear() : void`  \n  Clears all entries from the dict.\n- `size() : number`  \n  Returns the current number of entries.\n\n### Key Generation\n\n- `key( strs: string[], pfx?: string, sfx?: string, sorted: boolean = false ) : string | false`  \n  Generates a composite key from an array of strings. \n  - `strs`: Array of strings to hash.\n  - `pfx` / `sfx`: Optional prefix/suffix for the key.\n  - `sorted`: If true, sorts component hashes before joining (ensures order-independence).\n\n## Options\n\n- `hash` (string | function, default: `'fasthash'`)  \n  The hash algorithm to use. Built-in: `'fasthash'`, `'fnv1a'`, `'murmur3'`. Or a custom `( str: string, seed?: number ) =\u003e number`.\n- `seed` (number, default: `undefined`)  \n  Optional numeric seed for the hash function.\n- `maxStrLen` (number, default: `2048`)  \n  Maximum length allowed for input strings in `keygen`.\n- `maxSize` (number, default: `10000`)  \n  Maximum number of entries before eviction starts.\n- `maxCacheSize` (number, default: `100000`)  \n  Maximum number of internal hash-to-string mappings to cache.\n- `fifo` (boolean, default: `true`)  \n  Whether to automatically evict the oldest entry when `maxSize` is reached.\n\n## Customization\n\n### Custom Hash Algorithms\n\nPass a custom hash function that implements the `HashFn` signature:\n\n```ts\nconst myHash = ( str: string, seed?: number ) : number =\u003e {\n\t// your implementation\n\treturn someNumericHash;\n};\n\nconst dict = new Dict( { hash: myHash } );\n```\n\n### Overriding keygen()\n\nYou can extend the `Dict` class to implement your own key generation logic by overriding the `protected keygen()` method:\n\n```ts\nclass MyDict extends Dict {\n\tprotected override keygen ( strs: string[], pfx?: string, sfx?: string ) : string | false {\n\t\t// custom logic before or after default hashing\n\t\tconst baseKey = super.keygen( strs, pfx, sfx );\n\t\treturn baseKey ? `v1_${baseKey}` : false;\n\t}\n}\n```\n\n----\n\nCopyright (c) 2026 Paul Köhler (komed3). All rights reserved.  \nReleased under the MIT license. See LICENSE file in the project root for details.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkomed3%2Ffastdict","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fkomed3%2Ffastdict","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkomed3%2Ffastdict/lists"}