JSPM

  • Created
  • Published
  • Downloads 6824570
  • Score
    100M100P100Q218951F
  • License MIT

A simple code writer that assists with formatting and visualizing blocks of code.

Package Exports

  • code-block-writer

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (code-block-writer) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

code-block-writer

Build Status Coverage Status stable

A simple code writer that assists with formatting and visualizing blocks of code.

npm install --save code-block-writer
typings install npm:code-block-writer --save

Example

import CodeBlockWriter from "code-block-writer";

const writer = new CodeBlockWriter({ newLine: "\r\n" }); // optional options (newLine defaults to "\n")
const className = "MyClass";

writer.write(`class ${className} extends OtherClass`).block(() => {
    writer.writeLine(`@MyDecorator("myArgument1", "myArgument2")`);
    writer.write(`myMethod(myParam: any)`).block(() => {
        writer.write(`return this.post("myArgument");`);
    });
});

console.log(writer.toString());

Outputs:

class MyClass extends OtherClass {
   @MyDecorator("myArgument1", "myArgument2")
   myMethod(myParam: any) {
       return this.post("myArgument");
   }
}