# Observed-Remove Set and Map

[![CircleCI](https://circleci.com/gh/wehriam/observed-remove-level.svg?style=svg)](https://circleci.com/gh/wehriam/observed-remove-level) [![npm version](https://badge.fury.io/js/observed-remove-level.svg)](http://badge.fury.io/js/observed-remove-level) [![codecov](https://codecov.io/gh/wehriam/observed-remove-level/branch/master/graph/badge.svg)](https://codecov.io/gh/wehriam/observed-remove-level)

Eventually-consistent, conflict-free replicated data types (CRDT) [implemented](https://github.com/wehriam/observed-remove-level/blob/master/src/index.js) using [LevelDB](https://www.npmjs.com/package/level).

```js
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

<!-- Generated by documentation.js. Update this documentation by updating the source code. -->

### Table of Contents

## Map API

<!-- Generated by documentation.js. Update this documentation by updating the source code. -->

### Table of Contents
