Documentation
    Preparing search index...

    Buffer class to construct template output with proper indentation and formatting.

    The FileBuffer class provides a fluent API for building text output with automatic indentation management. It's commonly used for generating code or template files where proper formatting is important.

    const buffer = new FileBuffer()
    buffer
    .writeLine('function example() {')
    .indent()
    .writeLine('return "Hello World"')
    .dedent()
    .writeLine('}')
    console.log(buffer.flush())
    Index

    Constructors

    Accessors

    Methods

    Constructors

    Accessors

    • get size(): number

      Returns the size of buffer text

      Returns number

      The number of lines in the buffer

    Methods

    • Write a new line to the output with current indentation

      Parameters

      • text: string

        The text to write as a new line

      Returns this

      This FileBuffer instance for method chaining

    • Write text to the output without adding a new line

      Parameters

      • text: string

        The text to write without a newline

      Returns this

      This FileBuffer instance for method chaining

    • Increase indentation by 2 spaces

      Returns this

      This FileBuffer instance for method chaining

    • Decrease indentation by 2 spaces (minimum of 0)

      Returns this

      This FileBuffer instance for method chaining

    • Return template as a string, joining all buffer lines

      Once called, the output is cached and subsequent calls return the same result. The flush method becomes a no-op after the first call.

      Returns string

      The complete buffer content as a string