2.3.1 • Published 2 years ago

observed-remove-level v2.3.1

Weekly downloads
9
License
MIT
Repository
github
Last release
2 years ago

Observed-Remove Set and Map

CircleCI npm version codecov

Eventually-consistent, conflict-free replicated data types (CRDT) implemented using LevelDB.

const os = require('os');
const path = require('path');
const uuid = require('uuid');
const level = require('level');
const { ObservedRemoveMap } = require('observed-remove-level');

const run = async () => {

  const location = path.join(os.tmpdir(), uuid.v4());
  const db = level(location, { valueEncoding: 'json' });

  const alice = new ObservedRemoveMap(db, [], {namespace:"alice" });
  const bob = new ObservedRemoveMap(db, [], {namespace:"bob" });

  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));
  });

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

  // Later

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

Install

yarn add observed-remove-level

Set API

Table of Contents

Map API

Table of Contents

2.3.0

2 years ago

2.3.1

2 years ago

2.2.27

4 years ago

2.2.26

4 years ago

2.2.25

4 years ago

2.2.24

4 years ago

2.2.21

4 years ago

2.2.20

4 years ago

2.2.18

4 years ago

2.2.12

4 years ago

2.2.11

4 years ago

2.2.10

4 years ago

2.2.8

4 years ago

2.2.6

4 years ago

2.2.5

4 years ago