code-block-writer
Advanced tools
Comparing version 1.0.0 to 1.1.0
@@ -7,2 +7,3 @@ declare module "code-block-writer" { | ||
private _lastWasNewLine; | ||
constructor(opts?: { newLine: string }); | ||
block(block: () => void): CodeBlockWriter; | ||
@@ -9,0 +10,0 @@ writeLine(str: string): CodeBlockWriter; |
var CodeBlockWriter = (function () { | ||
function CodeBlockWriter() { | ||
function CodeBlockWriter(opts) { | ||
if (opts === void 0) { opts = null; } | ||
this._currentIndentation = 0; | ||
@@ -7,2 +8,3 @@ this._text = ""; | ||
this._lastWasNewLine = false; | ||
this._newline = (opts && opts.newLine) || "\n"; | ||
} | ||
@@ -31,3 +33,3 @@ CodeBlockWriter.prototype.block = function (block) { | ||
CodeBlockWriter.prototype.newLine = function () { | ||
this.write("\n"); | ||
this.write(this._newline); | ||
this._lastWasNewLine = true; | ||
@@ -39,3 +41,3 @@ return this; | ||
this._lastWasNewLine = false; | ||
if (str !== "\n") { | ||
if (str !== this._newline) { | ||
this.write(Array(this._getCurrentIndentationNumberSpaces()).join(" ")); | ||
@@ -42,0 +44,0 @@ } |
{ | ||
"name": "code-block-writer", | ||
"version": "1.0.0", | ||
"version": "1.1.0", | ||
"description": "A simple code writer that assists with formatting and visualizing blocks of code.", | ||
@@ -5,0 +5,0 @@ "main": "dist/code-block-writer.js", |
@@ -11,5 +11,5 @@ code-block-writer | ||
const writer = new CodeBlockWriter(); | ||
const writer = new CodeBlockWriter({ newLine: "\r\n" }); // optional options (newLine defaults to "\n") | ||
const className = "MyClass"; | ||
writer.write(`class ${className} extends OtherClass`).block(() => { | ||
@@ -16,0 +16,0 @@ writer.writeLine(`@MyDecorator("myArgument1", "myArgument2")`); |
@@ -6,3 +6,8 @@ export default class CodeBlockWriter { | ||
private _lastWasNewLine = false; | ||
private _newline: string; | ||
constructor(opts: { newLine: string } = null) { | ||
this._newline = (opts && opts.newLine) || "\n"; | ||
} | ||
block(block: () => void) { | ||
@@ -36,3 +41,3 @@ this.write(" {"); | ||
newLine() { | ||
this.write("\n"); | ||
this.write(this._newline); | ||
this._lastWasNewLine = true; | ||
@@ -47,3 +52,3 @@ | ||
if (str !== "\n") { | ||
if (str !== this._newline) { | ||
this.write(Array(this._getCurrentIndentationNumberSpaces()).join(" ")); | ||
@@ -50,0 +55,0 @@ } |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
9942
10
246