Skip to content
MichaelOstermannPublic

About

Functional operational-transform.

Resources

Stars

0 stars

Watchers

1 watching

Forks

Repository files navigation

delta

Functional operational-transform.

Differences from quill-delta

This library has been largely ported from quill-delta, some differences:

  • Immutable, functions take and return plain arrays
  • Support for nested attributes has been removed
  • Cloning is only done when the data actually changes
  • Deep-cloning has been replaced with shallow-cloning
  • One dependency, fast-diff

Example

import { Delta } from "@monstermann/delta";

// Create a document
const doc = Delta.insert([], "Hello world");

// Create a change that makes "Hello" bold
const change = Delta.retain([], 5, { bold: true });

// Apply the change
const result = Delta.compose(doc, change);
// [{ insert: "Hello", attributes: { bold: true } },
//  { insert: " world" }]

// Compute the difference between two documents
const a = Delta.insert([], "Hello");
const b = Delta.insert([], "Hello world");

Delta.diff(a, b);
// [{ retain: 5 },
//  { insert: " world" }]

Installation

bun add @monstermann/delta

API

Everything is documented with JSDoc, including examples.

Delta insert, retain, remove, push, compose, transform, invert, diff, concat, slice, chop, clean, equals, length
Op length

About

Functional operational-transform.

Resources

Stars

0 stars

Watchers

1 watching

Forks

Releases

Packages

Contributors

Languages