observed-remove

2.3.1 • Public • Published

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

/observed-remove/

    Package Sidebar

    Install

    npm i observed-remove

    Weekly Downloads

    2

    Version

    2.3.1

    License

    MIT

    Unpacked Size

    824 kB

    Total Files

    115

    Last publish

    Collaborators

    • wehriam