chop
ts
function Delta.chop<T>(ops: Delta<T>): Delta<T>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)
));
// [{ type: "insert", value: "Hello" }]
Delta.chop(pipe(
[],
Delta.insert("Hello"),
Delta.retain(5, { bold: true })
));
// [{ type: "insert", value: "Hello" },
// { type: "retain", value: 5, attributes: { bold: true } }]ts
import { Delta } from "@monstermann/delta";
pipe(
[],
Delta.insert("Hello"),
Delta.retain(5),
Delta.chop()
);
// [{ type: "insert", value: "Hello" }]