{"id":16490707,"url":"https://github.com/awinterman/vector-clock","last_synced_at":"2025-03-23T12:34:39.962Z","repository":{"id":12238116,"uuid":"14849881","full_name":"AWinterman/vector-clock","owner":"AWinterman","description":"A vector clock implementation for node.js","archived":false,"fork":false,"pushed_at":"2014-04-06T22:00:34.000Z","size":148,"stargazers_count":14,"open_issues_count":0,"forks_count":1,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-03-18T20:40:44.495Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","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/AWinterman.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":"2013-12-02T01:27:59.000Z","updated_at":"2022-04-13T03:21:47.000Z","dependencies_parsed_at":"2022-09-26T18:21:26.199Z","dependency_job_id":null,"html_url":"https://github.com/AWinterman/vector-clock","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/AWinterman%2Fvector-clock","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/AWinterman%2Fvector-clock/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/AWinterman%2Fvector-clock/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/AWinterman%2Fvector-clock/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/AWinterman","download_url":"https://codeload.github.com/AWinterman/vector-clock/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":245104460,"owners_count":20561377,"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-10-11T13:48:49.226Z","updated_at":"2025-03-23T12:34:39.668Z","avatar_url":"https://github.com/AWinterman.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"#`vector-clock-class`#\n\n## Overview ##\n\nA [vector clock][vclock-paper] is a data structure for keeping\ntrack of logical time for a set of events, allowing them to be partially\nordered.\n\nInstall it with\n\n```\nnpm install --save vector-clock-class\n```\n\n## API ##\n\n```javascript\nvar Clock = require('vector-clock-class')\n\nClock(\n    String | Number id,\n    (Integer start) | null\n) -\u003e vector_clock\n```\n\n- `id` should distinguish this clock from all the others. It is\nsaved to the class instance as `id`\n- `start` is an optional parameter which sets the version number from which the\nclock should start counting.\n\n## Methods and Attributes ##\n\nIn the methods below, `id` is a hashable object. Semantically, it should be the\nunique identifier of another clock.\n\n###`vector_clock.clock`###\n\nThe vector clock-- a map from `source_ids` to version numbers. Like the `C`\nfunction from [Lamport's paper][vclock-paper]. It's worth noting that this\nmeans this module plays well with [npm.im/vectorclock][vectorclock], although this\nbreaks the contract somewhat, since [mixu](https://github.com/mixu)'s library\nexpects object literals.\n\n###`vector_clock.get(id)` -\u003e `Integer version`###\n\nReturns the version number for the specified `id`, or `-Infinity` if it cannot be\nfound.\n\n###`vector_clock.update(id, version)` -\u003e `Integer|false`###\n\nBump the entry for a given id. `version` is required to ensure updates from\n*this* `vector_clock` which occur after the bump have a later version number.\nNote that the `version` is optional **only** if `id === vector_clock.id`. The\nreturn value is `false` if `version` is not specified when it should be.\nOtherwise it is the new version number for `id`.\n\n###`vector_clock.createReadStream()` -\u003e `stream`###\n\nThis method creates a stream; randomly orders the keys of the clock; pushes\nonto a newly-created readableStream one object of form  `{id: key, version: n}`\nper key; and then closes the stream. It also\n`vector_clock.update(vector_clock.id)`. This facilitates easily creating\ndigests of all the updates the clock has seen, useful for the [scuttlebutt][]\n\n# The competition #\n\nThere's already another [venerable vector clock](vectorclock) library out\nthere. This one more or less grew out of my [scuttlebutt][] implementation. It\ndiffers from [vectorclock][] in it's scope (slightly smaller), that it presents\na way to stream clock data out of it, and it's API.\n\n[vclock-paper]: http://research.microsoft.com/en-us/um/people/lamport/pubs/time-clocks.pdf\n[vectorclock]: https://npmjs.org/package/vectorclock\n[scuttlebutt]: https://github.com/AWinterman/simple-scuttle\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fawinterman%2Fvector-clock","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fawinterman%2Fvector-clock","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fawinterman%2Fvector-clock/lists"}