2 Object.defineProperty(exports, "__esModule", { value: true });
3 exports.wrapCell = void 0;
4 const utils_1 = require("./utils");
5 const wrapString_1 = require("./wrapString");
6 const wrapWord_1 = require("./wrapWord");
8 * Wrap a single cell value into a list of lines
10 * Always wraps on newlines, for the remainder uses either word or string wrapping
11 * depending on user configuration.
14 const wrapCell = (cellValue, cellWidth, useWrapWord) => {
15 // First split on literal newlines
16 const cellLines = (0, utils_1.splitAnsi)(cellValue);
17 // Then iterate over the list and word-wrap every remaining line if necessary.
18 for (let lineNr = 0; lineNr < cellLines.length;) {
21 lineChunks = (0, wrapWord_1.wrapWord)(cellLines[lineNr], cellWidth);
24 lineChunks = (0, wrapString_1.wrapString)(cellLines[lineNr], cellWidth);
26 // Replace our original array element with whatever the wrapping returned
27 cellLines.splice(lineNr, 1, ...lineChunks);
28 lineNr += lineChunks.length;
32 exports.wrapCell = wrapCell;
33 //# sourceMappingURL=wrapCell.js.map