# swarm-stamp

> Base64 Lamport timestamps =========================

Latest version **1.0.14** (published 2016-01-03) · MIT license · 0 weekly downloads

## Install

```sh
npm install swarm-stamp
pnpm add swarm-stamp
yarn add swarm-stamp
bun add swarm-stamp
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.14 |
| Published | 2016-01-03 |
| First published | 2015-12-01 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 2660 |
| Author | Victor Grishchenko |
| Maintainers | gritzko |

## Links

- npm: https://www.npmjs.com/package/swarm-stamp
- Repository: https://github.com/gritzko/swarm
- Homepage: http://github.com/gritzko/swarm
- Issues: https://github.com/gritzko/swarm/issues
- npm.io page: https://npm.io/package/swarm-stamp

## Recent versions

- 1.0.14 (latest) — 2016-01-03
- 1.0.5 (nightly) — 2015-12-17
- 1.0.12 — 2015-12-25
- 1.0.0 — 2015-12-01

## README

Base64 Lamport timestamps
=========================

![events](https://upload.wikimedia.org/wikipedia/commons/thumb/5/55/Vector_Clock.svg/750px-Vector_Clock.svg.png)

The package implements Base64 string Lamport timestamps. First described in ["Time, clocks, and the ordering of events in a distributed system"][paper] by Leslie Lamport these timestamps are designed to track events in a distributed system.
The paper's primary inspiration was the special theory of relativity.
It describes a model of time based on sequential communicating processes each having its local clocks only, no "newtonian" global universal clocks.

Hence, every timestamp has two components:

* monotonically increasing "clock" and
* process identifier.

These days, Lamport timestamps are used everywhere, starting from multicore CPUs all the way to world-scale distributed systems.

This implementation deals with base64 string based timestamps of variable length. Those are handier and more flexible than C-style fixed-width binary formats. Base64 can be used inside URLs (path/fragment parts), logs, arbitrary databases, etc.
Importantly, Base64 timestamps are human readable.

The clock component may be a simple sequential counteror a timestamp from a physical clock (data/time) or something inbetween or combined. (There are lots of fine details here.)
Classes:

* TestClock (sequential counter)
* MinuteClock (timestamp + sequence number, exact to a minute)
* SecondClock (timestamp + sequence number, exact to a second)
* AdabtableClock (timestamp + sequence number, long enough to guarantee uniqueness and monotonic growth)

Base64 timestamps obey alphanumeric order, that's why the package employs its own variety of base64. In common [base64 variants][base64], numeric order does not match alphanumeric order (i.e. the order for numbers and their base64 serializations differs).

swarm base64: `0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ_abcdefghijklmnopqrstuvwxyz~`

The package also implements two varieties of version vector based on Base64 Lamport timestamps:

* regular version vector (VVector, which is actually a map) and
* arrival order preserving version vector (OrdVVector).

See tests for usage examples.

[paper]: http://amturing.acm.org/p558-lamport.pdf
[base64]: https://en.wikipedia.org/wiki/Base64#Variants_summary_table

---
_Source: https://npm.io/package/swarm-stamp · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
