Skip to content

chop

ts
function Delta.chop(ops: Delta): Delta

Removes a trailing retain operation if it has no attributes.

Example

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

Delta.chop(pipe(
    [],
    Delta.insert("Hello"),
    Delta.retain(5)
));
// [{ insert: "Hello" }]

Delta.chop(pipe(
    [],
    Delta.insert("Hello"),
    Delta.retain(5, { bold: true })
));
// [{ insert: "Hello" },
//  { retain: 5, attributes: { bold: true } }]
ts
import { Delta } from "@monstermann/delta";

pipe(
    [],
    Delta.insert("Hello"),
    Delta.retain(5),
    Delta.chop()
);
// [{ insert: "Hello" }]