Constructor.
Optionalopts: Partial<CodeBlockWriterOptions>Options for the writer.
Writes a blank line.
Writes a blank line if the last written text was not a blank line.
Writes a block using braces.
Optionalblock: () => voidWrite using the writer within this block.
Writes text to exit a comment if in a comment.
Writes a blank line if the condition is true.
Condition to evaluate.
Writes a newline if the condition is true.
Condition to evaluate.
Conditionally writes text.
Condition to evaluate.
A function that returns a string to write if the condition is true.
Conditionally writes text.
Condition to evaluate.
Text to write if the condition is true.
Conditionally writes a line of text.
Condition to evaluate.
A function that returns a string to write if the condition is true.
Conditionally writes a line of text.
Condition to evaluate.
Text to write if the condition is true.
Gets if the writer ends with the provided text.
Text to check if the writer ends with the provided text.
Gets the current indentation level.
Gets the last char written.
Gets the length of the string in the writer.
Gets the options.
Writes the text within the provided action with hanging indentation.
Action to perform with hanging indentation.
Writes the text within the provided action with hanging indentation unless writing a block.
Action to perform with hanging indentation unless a block is written.
Indents the code one level for the current line.
Optionaltimes: numberIndents a block of code.
Block to indent.
Writes an inline block with braces.
Optionalblock: () => voidWrite using the writer within this block.
Gets if the writer is currently at the start of the first line of the text, block, or indentation block.
Gets if the writer is currently in a comment.
Gets if the writer is currently in a string.
Gets if the last chars written were for a blank line.
Gets if the last chars written were for a newline.
Gets if the last char written was a space.
Gets if the last char written was a tab.
Gets if the writer is currently on the first line of the text, block, or indentation block.
Iterates over the writer character char codes in reverse order. The iteration stops when a non-null or undefined value is returned from the action. The returned value is then returned by the method.
Writes a newline.
Writes a newline if the last line was not a newline.
Queues the indentation level for the next lines written.
Indentation level to queue.
Queues the indentation level for the next lines written using the provided indentation text.
Gets the indentation level from the indentation text.
Writes a quote character.
Writes text surrounded in quotes.
Text to write.
Sets the current indentation level.
Indentation level to be at.
Sets the current indentation using the provided indentation text.
Gets the indentation level from the indentation text.
Writes a space.
Optionaltimes: numberNumber of times to write a space.
Writes a space if the last character was not a space.
Writes a tab.
Optionaltimes: numberNumber of times to write a tab.
Writes a tab if the last character was not a tab.
Gets the writer's text.
Inserts text at the provided position.
This method is "unsafe" because it won't update the state of the writer unless inserting at the end position. It is biased towards being fast at inserting closer to the start or end, but slower to insert in the middle. Only use this if absolutely necessary.
Position to insert at.
Text to insert.
Sets the indentation level with the provided indentation text within the provided action and restores the writer's indentation state afterwards.
Gets the indentation level from the indentation text.
Action to perform with the indentation.
Writes the provided text.
Text to write.
Writes a line of text.
String to write.
Code writer that assists with formatting and visualizing blocks of JavaScript or TypeScript code.