Socket
Socket
Sign inDemoInstall

code-block-writer

Package Overview
Dependencies
Maintainers
1
Versions
85
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

code-block-writer - npm Package Compare versions

Comparing version 1.5.2 to 1.6.0

6

dist/code-block-writer.js

@@ -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 () {

2

package.json
{
"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 @@

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc