0.4.1 • Published 2 years ago

shared-event-log v0.4.1

Weekly downloads
-
License
ISC
Repository
github
Last release
2 years ago

shared-event-log

An event log that is shared betweeen two peers with deterministic references.

Usage

API

const log = new Log(id, [opts])

Instantiate a new Log with a given id

Options must include either store or storage:

{
  store, // corestore instance
  storage // storage for a new corestore
}

await log.loadRemote(remoteFeedKey)

Load the remote peer's hypercore

const event = await log.get(clock)

Returns a boolean whether a clock was generated by the local key or not.

await log.append(data)

Append data to the log.

const clock = log.clock()

Get the current clock.

for await (const event of log.getState(start, end))

Returns an async generator of all events added between two clocks: start and end.

Note: The set of updates will be the same for either peer, but the ordering may differ.

const isBefore = log.compare(a, b)

Returns a boolean of whether clock a is ordered before clock b or not.

const clock = log.union(a, b)

Returns a clock that is the union of two clocks. This clock in turn references the union of all events referenced by either clock.

const isLocal = log.isLocal(clock)

Returns a boolean whether a clock was generated by the local key or not.

0.4.1

2 years ago

0.3.0

2 years ago

0.2.1

2 years ago

0.2.0

2 years ago

0.4.0

2 years ago

0.1.0

2 years ago

0.0.1

2 years ago

0.0.0

2 years ago