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 7.1.0 to 7.2.0

10

CHANGELOG.md

@@ -5,2 +5,12 @@ # Change Log

<a name="7.2.0"></a>
# [7.2.0](https://github.com/dsherret/code-block-writer/compare/v7.1.0...v7.2.0) (2018-05-28)
### Features
* Allow passing in a decimal indentation level. ([c77fa14](https://github.com/dsherret/code-block-writer/commit/c77fa14))
<a name="7.1.0"></a>

@@ -7,0 +17,0 @@ # [7.1.0](https://github.com/dsherret/code-block-writer/compare/v7.0.0...v7.1.0) (2018-05-08)

28

dist/code-block-writer.js

@@ -7,2 +7,3 @@ "use strict";

function CodeBlockWriter(opts) {
if (opts === void 0) { opts = {}; }
this._currentIndentation = 0;

@@ -16,7 +17,7 @@ this._text = "";

this._isOnFirstLineOfBlock = true;
this._newLine = (opts && opts.newLine) || "\n";
this._useTabs = (opts && opts.useTabs) || false;
this._indentNumberOfSpaces = (opts && opts.indentNumberOfSpaces) || 4;
this._newLine = opts.newLine || "\n";
this._useTabs = opts.useTabs || false;
this._indentNumberOfSpaces = opts.indentNumberOfSpaces || 4;
this._indentationText = getIndentationText(this._useTabs, this._indentNumberOfSpaces);
this._quoteChar = (opts && opts.useSingleQuote) ? "'" : "\"";
this._quoteChar = opts.useSingleQuote ? "'" : "\"";
}

@@ -88,4 +89,3 @@ /**

this._isOnFirstLineOfBlock = false;
if (this._currentIndentation > 0)
this._currentIndentation--;
this._currentIndentation = Math.max(0, this._currentIndentation - 1);
};

@@ -383,3 +383,15 @@ CodeBlockWriter.prototype.conditionalWriteLine = function (condition, strOrFunc) {

CodeBlockWriter.prototype._writeIndentation = function () {
this._text += Array(this._currentIndentation + 1).join(this._indentationText);
var flooredIndentation = Math.floor(this._currentIndentation);
for (var i = 0; i < flooredIndentation; i++)
this._text += this._indentationText;
var overflow = this._currentIndentation - flooredIndentation;
if (this._useTabs) {
if (overflow > 0.5)
this._text += this._indentationText;
}
else {
var portion = Math.round(this._indentationText.length * overflow);
for (var i = 0; i < portion; i++)
this._text += this._indentationText[i];
}
};

@@ -402,3 +414,3 @@ CodeBlockWriter.prototype._newLineIfNewLineOnNextWrite = function () {

var _a = getSpacesAndTabsCount(countOrText), spacesCount = _a.spacesCount, tabsCount = _a.tabsCount;
return tabsCount + Math.round(Math.max(0, spacesCount - 1) / this._indentNumberOfSpaces);
return tabsCount + spacesCount / this._indentNumberOfSpaces;
}

@@ -405,0 +417,0 @@ else

{
"name": "code-block-writer",
"version": "7.1.0",
"version": "7.2.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",

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