code-block-writer
Advanced tools
@@ -16,2 +16,3 @@ var CodeBlockWriter = (function () { | ||
| block(); | ||
| this.removeLastIfNewLine(); | ||
| this._currentIndentation--; | ||
@@ -63,2 +64,7 @@ this.writeLine("}"); | ||
| }; | ||
| CodeBlockWriter.prototype.removeLastIfNewLine = function () { | ||
| if (this.isLastLineBlankLine() && this.isCurrentLineBlank()) { | ||
| this._text = this._text.substr(0, this._text.length - this._newLine.length); | ||
| } | ||
| }; | ||
| CodeBlockWriter.prototype.isCurrentLineBlank = function () { | ||
@@ -65,0 +71,0 @@ return this.getCurrentLine().length === 0; |
@@ -76,2 +76,10 @@ var assert = require("assert"); | ||
| }); | ||
| it("should remove a newline if the last thing before the block was a newline", function () { | ||
| var expected = "test {\n inside\n}\n"; | ||
| doTest(expected, function (writer) { | ||
| writer.write("test ").block(function () { | ||
| writer.writeLine("inside").newLine(); | ||
| }); | ||
| }); | ||
| }); | ||
| }); | ||
@@ -78,0 +86,0 @@ describe("writeLine()", function () { |
+1
-1
| { | ||
| "name": "code-block-writer", | ||
| "version": "1.5.2", | ||
| "version": "1.6.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", |
@@ -18,2 +18,3 @@ export default class CodeBlockWriter { | ||
| block(); | ||
| this.removeLastIfNewLine(); | ||
| this._currentIndentation--; | ||
@@ -83,2 +84,8 @@ this.writeLine("}"); | ||
| private removeLastIfNewLine() { | ||
| if (this.isLastLineBlankLine() && this.isCurrentLineBlank()) { | ||
| this._text = this._text.substr(0, this._text.length - this._newLine.length); | ||
| } | ||
| } | ||
| private isCurrentLineBlank() { | ||
@@ -85,0 +92,0 @@ return this.getCurrentLine().length === 0; |
@@ -110,2 +110,15 @@ import * as assert from "assert"; | ||
| }); | ||
| it("should remove a newline if the last thing before the block was a newline", () => { | ||
| const expected = | ||
| `test { | ||
| inside | ||
| } | ||
| `; | ||
| doTest(expected, writer => { | ||
| writer.write("test ").block(() => { | ||
| writer.writeLine("inside").newLine(); | ||
| }); | ||
| }); | ||
| }); | ||
| }); | ||
@@ -112,0 +125,0 @@ |
Network access
Supply chain riskThis module accesses the network.
Found 3 instances in 1 package
Shell access
Supply chain riskThis module accesses the system shell. Accessing the system shell increases the risk of executing arbitrary code.
Found 1 instance in 1 package
Long strings
Supply chain riskContains long string literals, which may be a sign of obfuscated or packed code.
Found 1 instance in 1 package
Network access
Supply chain riskThis module accesses the network.
Found 3 instances in 1 package
Shell access
Supply chain riskThis module accesses the system shell. Accessing the system shell increases the risk of executing arbitrary code.
Found 1 instance in 1 package
Long strings
Supply chain riskContains long string literals, which may be a sign of obfuscated or packed code.
Found 1 instance in 1 package
127409
1%2949
1.1%