massive update, probably broken
[dotfiles/.git] / .config / coc / extensions / node_modules / coc-prettier / node_modules / table / dist / src / wrapCell.js
1 "use strict";
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");
7 /**
8  * Wrap a single cell value into a list of lines
9  *
10  * Always wraps on newlines, for the remainder uses either word or string wrapping
11  * depending on user configuration.
12  *
13  */
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;) {
19         let lineChunks;
20         if (useWrapWord) {
21             lineChunks = (0, wrapWord_1.wrapWord)(cellLines[lineNr], cellWidth);
22         }
23         else {
24             lineChunks = (0, wrapString_1.wrapString)(cellLines[lineNr], cellWidth);
25         }
26         // Replace our original array element with whatever the wrapping returned
27         cellLines.splice(lineNr, 1, ...lineChunks);
28         lineNr += lineChunks.length;
29     }
30     return cellLines;
31 };
32 exports.wrapCell = wrapCell;
33 //# sourceMappingURL=wrapCell.js.map