{"id":30300318,"url":"https://github.com/bfncs/replicatable","last_synced_at":"2025-10-26T17:03:07.450Z","repository":{"id":51700424,"uuid":"212193531","full_name":"bfncs/replicatable","owner":"bfncs","description":"Library of CRDTs (Conflict-free replicated data types)","archived":false,"fork":false,"pushed_at":"2021-05-11T04:53:43.000Z","size":203,"stargazers_count":1,"open_issues_count":1,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-08-17T04:33:06.782Z","etag":null,"topics":["crdt","distributed","eventual-consistency","replication"],"latest_commit_sha":null,"homepage":"","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/bfncs.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2019-10-01T20:30:08.000Z","updated_at":"2021-07-03T11:25:56.000Z","dependencies_parsed_at":"2022-08-22T07:10:29.531Z","dependency_job_id":null,"html_url":"https://github.com/bfncs/replicatable","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/bfncs/replicatable","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bfncs%2Freplicatable","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bfncs%2Freplicatable/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bfncs%2Freplicatable/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bfncs%2Freplicatable/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/bfncs","download_url":"https://codeload.github.com/bfncs/replicatable/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bfncs%2Freplicatable/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":281139039,"owners_count":26450141,"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","status":"online","status_checked_at":"2025-10-26T02:00:06.575Z","response_time":61,"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":["crdt","distributed","eventual-consistency","replication"],"created_at":"2025-08-17T04:32:32.560Z","updated_at":"2025-10-26T17:03:07.431Z","avatar_url":"https://github.com/bfncs.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# replicatable\n\nLibrary of CRDTs (Conflict-free replicated data types) implemented in TypeScript\n\n## Implemented Types\n\n### Convergent replicated data types (CvRDTs), state based\n\nCvRDTs are replicated by sending the full local state to other replicas and calling the commutative, associative and idempotent `merge` function.\n\n#### `GCounter`\n\nThe `GCounter` (Grow-only-Counter) is a counter that can only be incremented on `n` nodes. Each node needs to be assigned a cluster-wide unique ID.\n\n```typescript\nimport { GCounter } from \"replicatable\";\nconst firstCounter = new GCounter('first');\nfirstCounter.increment(3);\n\nconst secondCounter = new GCounter('second');\nsecondCounter.increment(7);\n\nfirstCounter.merge(secondCounter);\n\nconsole.log(firstCounter.value); // 10\n```\n\n#### `PNCounter`\n\nThe `PNCounter` (Positive-Negative-Counter) combines two `GCounter` instances, one for increments and one for decrements.\n\n```typescript\nimport { PNCounter } from \"replicatable\";\nconst firstCounter = new PNCounter('first');\nfirstCounter.decrement(4);\n\nconst secondCounter = new PNCounter('second');\nsecondCounter.increment(6);\n\nfirstCounter.merge(secondCounter);\n\nconsole.log(firstCounter.value); // 2\n```\n\n#### `GSet`\n\nThe `GSet` (Grow-only-Set) is a set that only allows adds.\n\n```typescript\nimport { GSet } from \"replicatable\";\nconst firstSet = new GSet();\nfirstSet.add('foo');\n\nconst secondSet = new GSet();\nsecondSet.add('bar');\n\nfirstSet.merge(secondSet);\nconsole.log(firstSet) // Set(['foo', 'bar'])\n```\n\n#### `TwoPhaseSet`\n\nThe `TwoPhaseSet` is a set that only allows elements to be added and removed. It combines two `GSets` for additins and removals.\n\n```typescript\nimport { TwoPhaseSet } from \"replicatable\";\nconst firstSet = new TwoPhaseSet();\nfirstSet.add('foo');\nfirstSet.add('baz');\n\nconst secondSet = new TwoPhaseSet();\nsecondSet.add('bar');\nsecondSet.remove('baz');\n\nfirstSet.merge(secondSet);\nconsole.log(firstSet) // Set(['foo', 'bar'])\n```\n\n\n## Prior Work\n\n* [barend-erasmus/pangolin](https://github.com/barend-erasmus/pangolin)\n* [orbitdb/crdts](https://github.com/orbitdb/crdts)\n* [ljwagerfield/crdt](https://github.com/ljwagerfield/crdt)\n* [pfrazee/crdt_notes](https://github.com/pfrazee/crdt_notes)","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbfncs%2Freplicatable","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbfncs%2Freplicatable","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbfncs%2Freplicatable/lists"}