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

table

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

table - npm Package Compare versions

Comparing version 6.4.0 to 6.5.0

17

dist/wrapCell.js

@@ -6,4 +6,19 @@ "use strict";

Object.defineProperty(exports, "__esModule", { value: true });
const slice_ansi_1 = __importDefault(require("slice-ansi"));
const strip_ansi_1 = __importDefault(require("strip-ansi"));
const wrapString_1 = __importDefault(require("./wrapString"));
const wrapWord_1 = __importDefault(require("./wrapWord"));
const splitAnsi = (input) => {
const lengths = strip_ansi_1.default(input).split('\n').map(({ length }) => {
return length;
});
const result = [];
let startIndex = 0;
lengths.forEach((length) => {
result.push(length === 0 ? '' : slice_ansi_1.default(input, startIndex, startIndex + length));
// Plus 1 for the newline character itself
startIndex += length + 1;
});
return result;
};
/**

@@ -18,3 +33,3 @@ * Wrap a single cell value into a list of lines

// First split on literal newlines
const cellLines = cellValue.split('\n');
const cellLines = splitAnsi(cellValue);
// Then iterate over the list and word-wrap every remaining line if necessary.

@@ -21,0 +36,0 @@ for (let lineNr = 0; lineNr < cellLines.length;) {

35

dist/wrapWord.js

@@ -7,5 +7,5 @@ "use strict";

const slice_ansi_1 = __importDefault(require("slice-ansi"));
const string_width_1 = __importDefault(require("string-width"));
exports.default = (input, size) => {
let subject = input;
const strip_ansi_1 = __importDefault(require("strip-ansi"));
const calculateStringLengths = (input, size) => {
let subject = strip_ansi_1.default(input);
const chunks = [];

@@ -16,15 +16,26 @@ // https://regex101.com/r/gY5kZ1/1

let chunk;
chunk = re.exec(subject);
if (chunk) {
chunk = chunk[0];
subject = slice_ansi_1.default(subject, string_width_1.default(chunk));
chunk = chunk.trim();
const match = re.exec(subject);
if (match) {
chunk = match[0];
subject = subject.slice(chunk.length);
const trimmedLength = chunk.trim().length;
const offset = chunk.length - trimmedLength;
chunks.push([trimmedLength, offset]);
}
else {
chunk = slice_ansi_1.default(subject, 0, size);
subject = slice_ansi_1.default(subject, size);
chunk = subject.slice(0, size);
subject = subject.slice(size);
chunks.push([chunk.length, 0]);
}
chunks.push(chunk);
} while (string_width_1.default(subject));
} while (subject.length);
return chunks;
};
exports.default = (input, size) => {
const result = [];
let startIndex = 0;
calculateStringLengths(input, size).forEach(([length, offset]) => {
result.push(slice_ansi_1.default(input, startIndex, startIndex + length));
startIndex += length + offset;
});
return result;
};

@@ -13,3 +13,4 @@ {

"slice-ansi": "^4.0.0",
"string-width": "^4.2.0"
"string-width": "^4.2.0",
"strip-ansi": "^6.0.0"
},

@@ -94,3 +95,3 @@ "description": "Formats data into a string table.",

},
"version": "6.4.0"
"version": "6.5.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