drawContent.js
1 "use strict"; 2 Object.defineProperty(exports, "__esModule", { value: true }); 3 exports.drawContent = void 0; 4 /** 5 * Shared function to draw horizontal borders, rows or the entire table 6 */ 7 const drawContent = (contents, separatorConfig) => { 8 const { separatorGetter, drawSeparator } = separatorConfig; 9 const contentSize = contents.length; 10 const result = []; 11 if (drawSeparator(0, contentSize)) { 12 result.push(separatorGetter(0, contentSize)); 13 } 14 contents.forEach((content, contentIndex) => { 15 result.push(content); 16 // Only append the middle separator if the content is not the last 17 if (contentIndex + 1 < contentSize && drawSeparator(contentIndex + 1, contentSize)) { 18 result.push(separatorGetter(contentIndex + 1, contentSize)); 19 } 20 }); 21 if (drawSeparator(contentSize, contentSize)) { 22 result.push(separatorGetter(contentSize, contentSize)); 23 } 24 return result.join(''); 25 }; 26 exports.drawContent = drawContent;