Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

code-block-writer

Package Overview
Dependencies
Maintainers
1
Versions
86
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.0.0 to 1.1.0

1

code-block-writer.d.ts

@@ -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;

8

dist/code-block-writer.js
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

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