3 Object.defineProperty(exports, "__esModule", {
6 exports.default = void 0;
8 var _wrapString = _interopRequireDefault(require("./wrapString"));
10 var _wrapWord = _interopRequireDefault(require("./wrapWord"));
12 function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
15 * Wrap a single cell value into a list of lines
17 * Always wraps on newlines, for the remainder uses either word or string wrapping
18 * depending on user configuration.
20 * @param {string} cellValue
21 * @param {number} columnWidth
22 * @param {boolean} useWrapWord
25 const wrapCell = (cellValue, columnWidth, useWrapWord) => {
26 // First split on literal newlines
27 const cellLines = cellValue.split('\n'); // Then iterate over the list and word-wrap every remaining line if necessary.
29 for (let lineNr = 0; lineNr < cellLines.length;) {
33 lineChunks = (0, _wrapWord.default)(cellLines[lineNr], columnWidth);
35 lineChunks = (0, _wrapString.default)(cellLines[lineNr], columnWidth);
36 } // Replace our original array element with whatever the wrapping returned
39 cellLines.splice(lineNr, 1, ...lineChunks);
40 lineNr += lineChunks.length;
46 var _default = wrapCell;
47 exports.default = _default;
48 //# sourceMappingURL=wrapCell.js.map