{"id":13726102,"url":"https://github.com/kitten/pessimism","last_synced_at":"2025-05-07T21:31:29.307Z","repository":{"id":57322405,"uuid":"202388674","full_name":"kitten/pessimism","owner":"kitten","description":"A fast HAMT Map intended for KV caching and optimistic updates","archived":true,"fork":false,"pushed_at":"2020-09-06T22:08:27.000Z","size":410,"stargazers_count":15,"open_issues_count":4,"forks_count":3,"subscribers_count":2,"default_branch":"master","last_synced_at":"2024-08-10T09:15:11.890Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"OCaml","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/kitten.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2019-08-14T16:38:19.000Z","updated_at":"2023-01-28T12:23:29.000Z","dependencies_parsed_at":"2022-08-26T01:10:32.172Z","dependency_job_id":null,"html_url":"https://github.com/kitten/pessimism","commit_stats":null,"previous_names":[],"tags_count":5,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kitten%2Fpessimism","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kitten%2Fpessimism/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kitten%2Fpessimism/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kitten%2Fpessimism/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/kitten","download_url":"https://codeload.github.com/kitten/pessimism/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":224654139,"owners_count":17347677,"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":[],"created_at":"2024-08-03T01:02:52.666Z","updated_at":"2024-11-14T16:33:22.120Z","avatar_url":"https://github.com/kitten.png","language":"OCaml","funding_links":[],"categories":["OCaml"],"sub_categories":[],"readme":"\u003ch2 align=\"center\"\u003epessimism\u003c/h2\u003e\n\u003cp align=\"center\"\u003e\n\u003cstrong\u003eA fast and compact HAMT-based KV-Cache with optimistic entries\u003c/strong\u003e\n\u003c/p\u003e\n\n`pessimism` is a fast and compact KV-Cache primarily built for `@urql/exchange-graphcache`.\nIt's a functional and immutable HAMT structure, which increases structural sharing, while\nkeeping memory usage compact. It supports optimistic entries, which can be invalidated in a single go.\n\n## Usage\n\nThis library works with both TypeScript and BuckleScript (Reason/OCaml).\n\n```sh\nyarn add pessimism\n# or\nnpm install --save pessimism\n```\n\nThe basic methods support making a map and setting, getting, and removing entries:\n\n```js\nimport * as Map from 'pessimism';\n\nlet map = Map.set(Map.make(), \"key\", \"value\");\nMap.get(map, \"key\"); // \"value\"\n\nmap = Map.remove(map, \"key\");\nMap.get(map, \"key\"); // undefined\n```\n\nOptimistic entries can be set using `setOptimistic` and cleared using `clearOptimistic`:\n\n```js\nimport * as Map from 'pessimism';\n\nlet map = Map.set(Map.make(), \"key\", \"value\");\n// Set an optimistic entry with the ID 1\nmap = Map.setOptimistic(\"key\", \"temp\", 1);\n\nMap.get(map, \"key\"); // \"temp\" which is the optimistic value\n\n// Clear all optimistic entries with ID 1\nmap = Map.clearOptimistic(map, 1);\nMap.get(map, \"key\"); // \"value\" which was the original value\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkitten%2Fpessimism","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fkitten%2Fpessimism","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkitten%2Fpessimism/lists"}