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 12.0.0 to 13.0.0

3

esm/mod.js

@@ -39,3 +39,3 @@ import { escapeForWithinString, getStringFromStrOrFunc } from "./utils/string_utils.js";

*/
export default class CodeBlockWriter {
class CodeBlockWriter {
/**

@@ -859,2 +859,3 @@ * Constructor.

});
export default CodeBlockWriter;
function isRegExStart(currentChar, pastChar, pastPastChar) {

@@ -861,0 +862,0 @@ return pastChar === CHARS.FORWARD_SLASH

@@ -1,16 +0,19 @@

const newlineRegex = /(\r?\n)/g;
/** @internal */
export function escapeForWithinString(str, quoteKind) {
return escapeChar(str, quoteKind).replace(newlineRegex, "\\$1");
}
/** @internal */
export function escapeChar(str, char) {
if (char.length !== 1) {
throw new Error(`Specified char must be one character long.`);
}
let result = "";
// todo: reduce appends (don't go char by char)
for (let i = 0; i < str.length; i++) {
if (str[i] === char) {
if (str[i] === quoteKind) {
result += "\\";
}
else if (str[i] === "\r" && str[i + 1] === "\n") {
result += "\\";
i++; // skip the \r
}
else if (str[i] === "\n") {
result += "\\";
}
else if (str[i] === "\\") {
result += "\\";
}
result += str[i];

@@ -17,0 +20,0 @@ }

{
"module": "./esm/mod.js",
"main": "./script/mod.js",
"name": "code-block-writer",
"version": "12.0.0",
"version": "13.0.0",
"description": "A simple code writer that assists with formatting and visualizing blocks of code.",
"repository": {
"type": "git",
"url": "git+https://github.com/dsherret/code-block-writer.git"
},
"keywords": [

@@ -18,2 +12,7 @@ "code generation",

"author": "David Sherret",
"homepage": "https://github.com/dsherret/code-block-writer#readme",
"repository": {
"type": "git",
"url": "git+https://github.com/dsherret/code-block-writer.git"
},
"license": "MIT",

@@ -23,3 +22,4 @@ "bugs": {

},
"homepage": "https://github.com/dsherret/code-block-writer#readme",
"main": "./script/mod.js",
"module": "./esm/mod.js",
"exports": {

@@ -35,8 +35,9 @@ ".": {

"devDependencies": {
"@types/node": "^18.11.9",
"chalk": "^4.1.2",
"@types/node": "^20.9.0",
"picocolors": "^1.0.0",
"@types/chai": "4.3",
"chai": "4.3.7",
"@deno/shim-deno": "~0.13.0"
}
"@deno/shim-deno": "~0.17.0"
},
"_generatedBy": "dnt@0.39.0"
}

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

}
exports.default = CodeBlockWriter;
/** @internal */

@@ -862,2 +861,3 @@ Object.defineProperty(CodeBlockWriter, "_newLineRegEx", {

});
exports.default = CodeBlockWriter;
function isRegExStart(currentChar, pastChar, pastPastChar) {

@@ -864,0 +864,0 @@ return pastChar === CHARS.FORWARD_SLASH

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.getStringFromStrOrFunc = exports.escapeChar = exports.escapeForWithinString = void 0;
const newlineRegex = /(\r?\n)/g;
exports.getStringFromStrOrFunc = exports.escapeForWithinString = void 0;
/** @internal */
function escapeForWithinString(str, quoteKind) {
return escapeChar(str, quoteKind).replace(newlineRegex, "\\$1");
}
exports.escapeForWithinString = escapeForWithinString;
/** @internal */
function escapeChar(str, char) {
if (char.length !== 1) {
throw new Error(`Specified char must be one character long.`);
}
let result = "";
// todo: reduce appends (don't go char by char)
for (let i = 0; i < str.length; i++) {
if (str[i] === char) {
if (str[i] === quoteKind) {
result += "\\";
}
else if (str[i] === "\r" && str[i + 1] === "\n") {
result += "\\";
i++; // skip the \r
}
else if (str[i] === "\n") {
result += "\\";
}
else if (str[i] === "\\") {
result += "\\";
}
result += str[i];

@@ -24,3 +26,3 @@ }

}
exports.escapeChar = escapeChar;
exports.escapeForWithinString = escapeForWithinString;
/** @internal */

@@ -27,0 +29,0 @@ function getStringFromStrOrFunc(strOrFunc) {

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