# lseqtree

> A data structure for distributed arrays using the LSeq allocation strategy.

Latest version **1.0.0** (published 2017-07-06) · MIT license · 0 weekly downloads

## Install

```sh
npm install lseqtree
pnpm add lseqtree
yarn add lseqtree
bun add lseqtree
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.0 |
| Published | 2017-07-06 |
| First published | 2014-10-14 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 2 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | Chat-Wane |
| Maintainers | chat-wane |
| Keywords | distributed structure, CRDT, LSeq, tree, array |

## Links

- npm: https://www.npmjs.com/package/lseqtree
- Repository: https://github.com/chat-wane/LSEQTree
- Homepage: https://github.com/chat-wane/LSEQTree#readme
- Issues: https://github.com/chat-wane/LSEQTree/issues
- npm.io page: https://npm.io/package/lseqtree

## Dependencies (2)

- [BigInt](https://npm.io/package/BigInt.md) ^5.4.5
- [lodash](https://npm.io/package/lodash.md) ^4.17.4

## Recent versions

- 1.0.0 (latest) — 2017-07-06
- 0.3.5 — 2016-01-06
- 0.3.4 — 2015-09-28
- 0.3.3 — 2015-09-28
- 0.3.2 — 2015-08-12
- 0.3.0 — 2015-07-01
- 0.1.2 — 2014-11-06
- 0.1.1 — 2014-11-06
- 0.1.0 — 2014-10-14

## README

# LSEQTree

*Keywords: distributed systems, collaborative editing, CRDT, LSEQ allocation strategy, unique identifiers, tree-based array*

This project aims to provide an implementation of a CRDT-based array [1] with 
an underlying exponential tree and the allocation strategy LSeq [2].

## Installation

```
$ npm install lseqtree
```

## Usage

To include LSeqTree within your web browser, put the following line in your
html:

```html
<script src="./path/to/bundle/lseqtree.bundle.js"></script>
```

In your JavaScript file:

```javascript
const LSeqTree = require('lseqtree');
```

## Example

```javascript
// #1 We create a first distributed data structure for sequences'
const lseq1 = new LSeqTree(1);

// #2 We insert an element in the structure
const idInsert = lseq1.insert('A', 0);
console.log('\tSize of the 1st structure: ' + lseq1.length);
// > Size of the 1st structure: 1

console.log('#A We initialize a second structure');
const lseq2 = new LSeqTree(2);

// #B We insert the element of the first structure
lseq2.applyInsert(idInsert);
console.log('\tSize of the 1st structure: ' + lseq1.length);
console.log('\tSize of the 2nd structure: ' + lseq2.length);
// > Size of the 1st structure: 1
// > Size of the 1st structure: 1

console.log('\tCharacter at index 0: ' + lseq1.get(0));
// > Character at index 0: A

// #C We remove the element at position 0, ie, character "A"
const idDelete = lseq2.remove(0);
console.log('\tSize of the 1st structure: ' + lseq1.length);
console.log('\tSize of the 2nd structure: ' + lseq2.length);
// > Size of the 1st structure: 1
// > Size of the 2nd structure: 0

// #3 We apply the removal to the first structure
lseq1.applyRemove(idDelete);
console.log('\tSize of the 1st structure: ' + lseq1.length);
console.log('\tSize of the 2nd structure: ' + lseq2.length);
// > Size of the 2nd structure: 0
// > Size of the 2nd structure: 0
```

## Misc

* [Clojure LSEQTree](https://github.com/Tavistock/lseq-tree.git) from
[Travis McNeill](https://github.com/Tavistock)

* [Prior project](https://github.com/chat-wane/lseqarray.git) ~~follows the
specification of LSEQTree~~. Nevertheless, the former is a linearization of the 
tree into an array. As such, the memory usage is high. On the other hand,
LSEQTree uses a tree, and therefore, it has a better space complexity. LSEQTree
uses the core of the prior project to generate its identifiers.
Despite being less efficient (obviously, the code must be improved), ~~it
provides interoperability and interchangeability between the two projects~~.

## References

[1] M. Shapiro, N. Preguiça, C. Baquero, and M. Zawirski. [A comprehensive study
of Convergent and Commutative Replicated Data
Types](http://hal.upmc.fr/docs/00/55/55/88/PDF/techreport.pdf). *Research
Report.* 2011.

[2] B. Nédelec, P. Molli, A. Mostéfaoui, and E. Desmontils. [LSEQ: an Adaptive
Structure for Sequences in Distributed Collaborative
Editing](http://hal.archives-ouvertes.fr/docs/00/92/16/33/PDF/fp025-nedelec.pdf).
*DocEng '13 Proceedings of the 2013 ACM symposium on Document engineering. Pages
37-46.* Sept. 2013.

---
_Source: https://npm.io/package/lseqtree · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
