The abstract base class for operations that can be applied by TextRewriterTransform.
export declare abstract class TextRewriter
The TextRewriterTransform applies one or more character rewriting operations to its chunk stream. Since these operations are applied separately to
stdout, the state is stored in an opaque
TextRewriter subclass is very similar to a regular expression, with the difference that
RegExp operates on a text string, whereas
TextRewriter operates on a stream of characters.
A rewriting operation starts with
initialize(), followed by any number of
process() calls, and then finishes with
close(). For example:
const rewriter: NormalizeNewlinesTextRewriter = new NormalizeNewlinesTextRewriter(NewlineKind.Lf);
const state: TextRewriterState = rewriter.initialize();
let output: string = rewriter.process(state, 'line 1\r');
output += rewriter.process(state, '\nline 2\r\n');
output += rewriter.close(state);
// The final "output" value is: "line 1\nline 2\n"
close() has been called, the
TextRewriterState state should not be reused.
|close(state)||Close the |
|initialize()||Create a new |
|process(state, input)||Rewrite the next sequence of characters from the input stream, returning the modified output.|