observed-remove
[![CircleCI](https://circleci.com/gh/wehriam/observed-remove.svg?style=svg)](https://circleci.com/gh/wehriam/observed-remove) [![npm version](https://badge.fury.io/js/observed-remove.svg)](http://badge.fury.io/js/observed-remove) [![codecov](https://codec
Last updated 4 months ago by wehriam .
MIT · Repository · Bugs · Original npm · Tarball · package.json
$ cnpm install observed-remove 
SYNC missed versions from official npm registry.

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

ObservedRemoveSet

Extends EventEmitter

Class representing an observed-remove set

Implements all methods and iterators of the native Set object in addition to the following. See: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Set

Parameters

  • entries Iterable<T> Iterable of initial values (optional, default [])
  • options Object (optional, default {})

sync

Emit a 'publish' event containing a specified queue or all of the set's insertions and deletions.

Parameters
  • queue Array<Array<any>> Array of insertions and deletions (optional, default this.dump())

Returns void

dump

Return an array containing all of the set's insertions and deletions.

process

Process an array of insertion and deletions.

Parameters
  • queue Array<Array<any>> Array of insertions and deletions
  • skipFlush (optional, default false)

Returns void

Map API

Table of Contents

ObservedRemoveMap

Extends EventEmitter

Class representing a Observed Remove Map

Implements all methods and iterators of the native Map object in addition to the following. See: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Map

Parameters

  • entries
  • options (optional, default {})

sync

Emit a 'publish' event containing a specified queue or all of the set's insertions and deletions.

Parameters
  • queue Array<Array<any>> Array of insertions and deletions (optional, default this.dump())

Returns void

dump

Return an array containing all of the map's insertions and deletions.

Current Tags

  • 2.2.26                                ...           latest (4 months ago)

34 Versions

  • 2.2.26                                ...           4 months ago
  • 2.2.7                                ...           4 months ago
  • 2.2.6                                ...           7 months ago
  • 2.2.5                                ...           a year ago
  • 2.2.4                                ...           a year ago
  • 2.2.3                                ...           a year ago
  • 2.2.2                                ...           a year ago
  • 2.2.1                                ...           a year ago
  • 2.2.0                                ...           a year ago
  • 2.1.0                                ...           a year ago
  • 2.0.4                                ...           a year ago
  • 2.0.3                                ...           2 years ago
  • 2.0.2                                ...           2 years ago
  • 2.0.1                                ...           2 years ago
  • 2.0.0                                ...           2 years ago
  • 1.5.6                                ...           2 years ago
  • 1.5.5                                ...           3 years ago
  • 1.5.4                                ...           3 years ago
  • 1.5.3                                ...           3 years ago
  • 1.5.2                                ...           3 years ago
  • 1.5.1                                ...           3 years ago
  • 1.5.0                                ...           3 years ago
  • 1.4.2                                ...           3 years ago
  • 1.4.1                                ...           3 years ago
  • 1.4.0                                ...           3 years ago
  • 1.3.4                                ...           3 years ago
  • 1.3.3                                ...           3 years ago
  • 1.3.2                                ...           3 years ago
  • 1.3.1                                ...           3 years ago
  • 1.3.0                                ...           3 years ago
  • 1.2.0                                ...           3 years ago
  • 1.1.3                                ...           3 years ago
  • 1.1.2                                ...           3 years ago
  • 1.1.0                                ...           3 years ago
Maintainers (1)
Downloads
Today 0
This Week 0
This Month 0
Last Day 0
Last Week 0
Last Month 0
Dependencies (3)

Copyright 2014 - 2016 © taobao.org |