Skip to content

Eventually-consistent, conflict-free replicated sets and maps

Notifications You must be signed in to change notification settings

wehriam/observed-remove

Repository files navigation

Observed-Remove Set and Map

CircleCI npm version codecov

Eventually-consistent, conflict-free replicated data types (CRDT) implemented using native Map and Set objects.

const { ObservedRemoveSet } = require('observed-remove');

const alice = new ObservedRemoveSet();
const bob = new ObservedRemoveSet();

alice.on('publish', (message) => {
  setTimeout(() => bob.process(message), Math.round(Math.random() * 1000));
});

bob.on('publish', (message) => {
  setTimeout(() => alice.process(message), Math.round(Math.random() * 1000));
});

alice.add('foo');
bob.add('bar');

// Later

alice.has('bar'); // true
bob.has('foo'); // true
const { ObservedRemoveMap } = require('observed-remove');

const alice = new ObservedRemoveMap();
const bob = new ObservedRemoveMap();

alice.on('publish', (message) => {
  setTimeout(() => bob.process(message), Math.round(Math.random() * 1000));
});

bob.on('publish', (message) => {
  setTimeout(() => alice.process(message), Math.round(Math.random() * 1000));
});

alice.set('a', 1);
bob.add('b', 2);

// Later

alice.get('b'); // 2
bob.get('a'); // 1

Install

yarn add observed-remove

Set API

Table of Contents

Map API

Table of Contents

About

Eventually-consistent, conflict-free replicated sets and maps

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published