# crdt-continuous-sequence

> ## Install

Latest version **1.0.1** (published 2019-11-11) · ISC license · 0 weekly downloads

## Install

```sh
npm install crdt-continuous-sequence
pnpm add crdt-continuous-sequence
yarn add crdt-continuous-sequence
bun add crdt-continuous-sequence
```

## Health

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

Positive: has types; no vulnerabilities; high quality score.

Warnings: low downloads; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.1 |
| Published | 2019-11-11 |
| First published | 2019-11-10 |
| Weekly downloads | 0 |
| License | ISC |
| TypeScript types | bundled |
| Module format | CommonJS |
| Dependencies | 0 |
| Unpacked size | 11 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Maintainers | nmaro |

## Links

- npm: https://www.npmjs.com/package/crdt-continuous-sequence
- npm.io page: https://npm.io/package/crdt-continuous-sequence

## Recent versions

- 1.0.1 (latest) — 2019-11-11
- 1.0.0 — 2019-11-10

## README

# CRDT Continuous Sequence

## Install

```
npm i -s crdt-continuous-sequence
```

## Usage with plain array

```js
import { ContinuousSequence } from 'crdt-continuous-sequence'

const cs = new ContinuousSequence();

const todos = [
    {
        id: 1
        name: "Groceries"
    },
    {
        id: 2,
        name: "Cleaning"
    },
    {
        id: 3,
        name: "Admin"
    }
]

// move 'Admin' between 'Groceries' and 'Cleaning'
cs.move(todos[2], todos[0], todos[1]);
cs.sort(todos);
console.log(todos);
```

## Usage with GUN

```js
import Gun from 'gun/gun'
import { GunContinuousSequence } from 'crdt-continuous-sequence'

const gun = Gun();

cs = new GunContinuousSequence(gun);

// Initialize sequence
gun.get('todos')
    .set({ name: "Groceries" })
    .set({ name: "Cleaning"})
    .set({ name: "Admin" })

// Load items
const todos = [];
gun.get('todos').map().on(todo => {
    let index
    if ((index = todos.findIndex(todo['_']['#'])) > -1) {
        todos[index] = {...todos[index], todo}
    } else {
        todos.push(todo)
    }
    cs.sort(todos);
})

// Later

// move 'Admin' between 'Groceries' and 'Cleaning'
cs.move(todos[3], todos[0], todos[1])
```

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