The writer is a library that was created to assist in developing multi-line strings for such things as code generation, documentation and error handling with custom templates.
Installation
npm install @ao-framework/writer
Import
import Writer from "@ao-framework/writer";
Usage
import Writer from "@ao-framework/writer";
let str = new Writer()
.align("left")
.indent(2)
.line("I should be right against edge.")
.line("So should I.", () => {
writer.line("I should be indented 2 spaces", () => {
writer.line("I should be indented 4 spaces")
})
}).getString()
console.log(str)
Outputs
I should be right against edge.
So should I.
I should be indented 2 spaces
I should be indented 4 spaces