{"id":37706085,"url":"https://github.com/mode89/fdtrie-js","last_synced_at":"2026-01-16T13:08:39.067Z","repository":{"id":59007327,"uuid":"534668643","full_name":"mode89/fdtrie-js","owner":"mode89","description":"Persistent data structures with fast diff","archived":false,"fork":false,"pushed_at":"2022-10-10T09:19:52.000Z","size":198,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-09-18T01:44:36.057Z","etag":null,"topics":["functional-programming","immutable-collections","javascript","persistent-data-structure"],"latest_commit_sha":null,"homepage":"","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/mode89.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}},"created_at":"2022-09-09T14:07:22.000Z","updated_at":"2022-09-14T07:35:30.000Z","dependencies_parsed_at":"2023-01-19T19:03:09.274Z","dependency_job_id":null,"html_url":"https://github.com/mode89/fdtrie-js","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"purl":"pkg:github/mode89/fdtrie-js","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mode89%2Ffdtrie-js","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mode89%2Ffdtrie-js/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mode89%2Ffdtrie-js/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mode89%2Ffdtrie-js/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/mode89","download_url":"https://codeload.github.com/mode89/fdtrie-js/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mode89%2Ffdtrie-js/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28478930,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-16T11:59:17.896Z","status":"ssl_error","status_checked_at":"2026-01-16T11:55:55.838Z","response_time":107,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"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":["functional-programming","immutable-collections","javascript","persistent-data-structure"],"created_at":"2026-01-16T13:08:39.001Z","updated_at":"2026-01-16T13:08:39.060Z","avatar_url":"https://github.com/mode89.png","language":"JavaScript","readme":"# fdtrie-js\nPersistent data structures with fast diff.\n\n## Usage\n\nInstallation\n```\nnpm install fdtrie\n```\n\nImport\n```js\nimport {PHashMap} from \"fdtrie\";\n```\n\nCreate an empty persistent hash map\n```js\nconst m0  = PHashMap.blank();\n```\n\nAdd entry into the map (returns new map object)\n```js\nconst m1 = m0.assoc(\"some-key\", \"some-value\");\n```\n\nRemove entry from the map (returns new map object)\n```js\nconst m2 = m1.dissoc(\"some-key\");\n```\n\nGet value by key (returns `undefined` if key not found)\n```js\nconst someValue = m1.get(\"some-key\");\n```\n\nGet value by key and return `notFound` if key not found\n```js\nconst notFound = {};\nconst anotherValue = m1.get(\"another-value\", notFound);\n```\n\nCount entries\n```js\nconst n = m1.count();\n```\n\nIterate through key-value pairs (returns generator object)\n```js\nfor (const e of m1.entries()) {\n    console.log(e.key, e.value);\n}\n```\n\nReduce difference between two maps by calling one of the callbacks\n(remove, change, add) on each of the differing entries\n```js\nconst accInit = 0;\nconst acc = m1.reduceDifference(m2, accInit, {\n    remove: (m1Entry, acc) =\u003e acc + m1Entry.key + m1Entry.value,\n    change: (m1Entry, m2Entry, acc) =\u003e\n        acc + m1Entry.key + m1Entry.value + m2Entry.value,\n    add: (m2Entry, acc) =\u003e acc + m2Entry.key + m2Entry.value,\n});\n```\n\nCalculate difference (returns a map that holds key-value pairs of the first map, which don't present in the second map)\n```js\nconst m3 = m1.difference(m0);\n```\n\n## Testing\n\nRun unit tests\n```\nnpm test\n```\n\nRun property-based tests\n```\nnpm run test-props\n```\n\n## Benchmarking\n\nRun benchmarks\n```\nnpm run bench\n```\n\nResults:\n```\nCPU: Intel Core i5-9400F\nRAM: 16 GB\nLinux kernel: 5.19.12\nNode v18.10.0\n\nAssociate a key with a value\n  PHashMap: 51 ms\n  ImmutableJS: 51 ms\n  Mori: 49 ms\n  Native: 8 ms\n\nGet a value by a key\n  PHashMap: 13 ms\n  ImmutableJS: 12 ms\n  Mori: 8 ms\n  Native: 1 ms\n\nDelete a key\n  PHashMap: 48 ms\n  ImmutableJS: 49 ms\n  Mori: 54 ms\n  Native: 0 ms\n\nSingle key difference\n  PHashMap: 949 ns\n  ImmutableJS: 8545869 ns\n  Mori: 5904032 ns\n\nAll keys difference\n  PHashMap: 10 ms\n  ImmutableJS: 43 ms\n  Mori: 27 ms\n\nReduce difference (single key)\n  PHashMap: 458 ns\n  ImmutableJS: 18070695 ns\n  Mori: 11168898 ns\n\nReduce difference (all keys)\n  PHashMap: 7 ms\n  ImmutableJS: 23 ms\n  Mori: 15 ms\n```\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmode89%2Ffdtrie-js","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmode89%2Ffdtrie-js","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmode89%2Ffdtrie-js/lists"}