# @netless/y

> Glue between netless app and crdt libraries

Latest version **0.1.5** (published 2022-08-17) · MIT license · 0 weekly downloads

## Install

```sh
npm install @netless/y
pnpm add @netless/y
yarn add @netless/y
bun add @netless/y
```

## Health

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

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

Warnings: low downloads; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.1.5 |
| Published | 2022-08-17 |
| First published | 2022-07-25 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Dependencies | 0 |
| Unpacked size | 15 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Maintainers | vince-hz, alic_zhang, straybugs, moskize, netless-rick, yleaf, herewhite, black_hole, cheerchen, l1shen, hyrious, huaguzheng |
| Keywords | netless, netless-app, crdt, yjs |

## Links

- npm: https://www.npmjs.com/package/@netless/y
- npm.io page: https://npm.io/package/@netless/y

## Recent versions

- 0.1.5 (latest) — 2022-08-17
- 0.2.0-canary.1 (canary) — 2023-04-06
- 0.2.0-canary.0 — 2022-09-23
- 0.1.4 — 2022-08-08
- 0.1.3 — 2022-07-25
- 0.1.2 — 2022-07-25
- 0.1.1 — 2022-07-25
- 0.1.0 — 2022-07-25

## README

## @netless/y

> Glue between netless app and CRDT libraries

```js
import { createVector } from "@netless/y";
// var App = { kind, setup(context) {
const vector = createVector(context, "namespace");
vector.forEach((update) => CRDT.applyUpdate(update));
CRDT.on("update", (update) => vector.push(update));
vector.on("update", (update) => CRDT.applyUpdate(update));
```

See [src/yjs.ts](./src/yjs.ts) for a more real-life use case.

### Structure

#### Vector

Think of it as a growing array, you can push CRDT operations into it.

```ts
type Value = any; // any JSON-serializable value

class Vector {
  readonly size: number;
  forEach(callback: (update: Value, index: number) => void): void;
  push(update: Value): void;
  swap(updates: Value[]): void;
  on(event: "update", callback: (update: Value) => void): void;
}
```

## License

MIT @ [netless](https://github.com/netless-io)

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