Skip to content

Commit

Permalink
Add JSON (de)serialization for change sets
Browse files Browse the repository at this point in the history
  • Loading branch information
marijnh committed Aug 29, 2020
1 parent b67e7be commit 5c53e27
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions src/text.ts
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,15 @@ export abstract class Text implements Iterable<string> {
/// @internal
toString() { return this.sliceString(0) }

/// Convert the document to an array of lines (which can be
/// deserialized again via [`Text.of`](#text.Text^of).
toJSON() {
let lines: string[] = []
for (let iter = this.iterLines(); !iter.next().done;)
lines.push(iter.value)
return lines
}

/// @internal
protected constructor() {}

Expand Down

0 comments on commit 5c53e27

Please sign in to comment.