UNPKG

opennms

Version:

Client API for the OpenNMS network monitoring platform

1 lines 37.2 kB
{"remainingRequest":"/data/node_modules/babel-loader/lib/index.js!/data/node_modules/cli-table2/src/cell.js","dependencies":[{"path":"/data/node_modules/cli-table2/src/cell.js","mtime":1553611387012},{"path":"/data/.babelrc","mtime":1553611371556},{"path":"/data/node_modules/cache-loader/dist/cjs.js","mtime":1553611387012},{"path":"/data/node_modules/babel-loader/lib/index.js","mtime":1553611386992}],"contextDependencies":[],"result":["'use strict';\n\nvar _typeof = typeof Symbol === \"function\" && typeof Symbol.iterator === \"symbol\" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === \"function\" && obj.constructor === Symbol && obj !== Symbol.prototype ? \"symbol\" : typeof obj; };\n\nvar _ = require('lodash');\nvar utils = require('./utils');\n\n/**\n * A representation of a cell within the table.\n * Implementations must have `init` and `draw` methods,\n * as well as `colSpan`, `rowSpan`, `desiredHeight` and `desiredWidth` properties.\n * @param options\n * @constructor\n */\nfunction Cell(options) {\n this.setOptions(options);\n}\n\nCell.prototype.setOptions = function (options) {\n if (_.isString(options) || _.isNumber(options) || _.isBoolean(options)) {\n options = { content: '' + options };\n }\n options = options || {};\n this.options = options;\n var content = options.content;\n if (_.isString(content) || _.isNumber(content) || _.isBoolean(content)) {\n this.content = String(content);\n } else if (!content) {\n this.content = '';\n } else {\n throw new Error('Content needs to be a primitive, got: ' + (typeof content === 'undefined' ? 'undefined' : _typeof(content)));\n }\n this.colSpan = options.colSpan || 1;\n this.rowSpan = options.rowSpan || 1;\n};\n\nCell.prototype.mergeTableOptions = function (tableOptions, cells) {\n this.cells = cells;\n\n var optionsChars = this.options.chars || {};\n var tableChars = tableOptions.chars;\n var chars = this.chars = {};\n _.forEach(CHAR_NAMES, function (name) {\n setOption(optionsChars, tableChars, name, chars);\n });\n\n this.truncate = this.options.truncate || tableOptions.truncate;\n\n var style = this.options.style = this.options.style || {};\n var tableStyle = tableOptions.style;\n setOption(style, tableStyle, 'padding-left', this);\n setOption(style, tableStyle, 'padding-right', this);\n this.head = style.head || tableStyle.head;\n this.border = style.border || tableStyle.border;\n\n var fixedWidth = tableOptions.colWidths[this.x];\n if (tableOptions.wordWrap && fixedWidth) {\n fixedWidth -= this.paddingLeft + this.paddingRight;\n this.lines = utils.colorizeLines(utils.wordWrap(fixedWidth, this.content));\n } else {\n this.lines = utils.colorizeLines(this.content.split('\\n'));\n }\n\n this.desiredWidth = utils.strlen(this.content) + this.paddingLeft + this.paddingRight;\n this.desiredHeight = this.lines.length;\n};\n\n/**\n * Each cell will have it's `x` and `y` values set by the `layout-manager` prior to\n * `init` being called;\n * @type {Number}\n */\n\nCell.prototype.x = null;\nCell.prototype.y = null;\n\n/**\n * Initializes the Cells data structure.\n *\n * @param tableOptions - A fully populated set of tableOptions.\n * In addition to the standard default values, tableOptions must have fully populated the\n * `colWidths` and `rowWidths` arrays. Those arrays must have lengths equal to the number\n * of columns or rows (respectively) in this table, and each array item must be a Number.\n *\n */\nCell.prototype.init = function (tableOptions) {\n var x = this.x;\n var y = this.y;\n this.widths = tableOptions.colWidths.slice(x, x + this.colSpan);\n this.heights = tableOptions.rowHeights.slice(y, y + this.rowSpan);\n this.width = _.reduce(this.widths, sumPlusOne);\n this.height = _.reduce(this.heights, sumPlusOne);\n\n this.hAlign = this.options.hAlign || tableOptions.colAligns[x];\n this.vAlign = this.options.vAlign || tableOptions.rowAligns[y];\n\n this.drawRight = x + this.colSpan == tableOptions.colWidths.length;\n};\n\n/**\n * Draws the given line of the cell.\n * This default implementation defers to methods `drawTop`, `drawBottom`, `drawLine` and `drawEmpty`.\n * @param lineNum - can be `top`, `bottom` or a numerical line number.\n * @param spanningCell - will be a number if being called from a RowSpanCell, and will represent how\n * many rows below it's being called from. Otherwise it's undefined.\n * @returns {String} The representation of this line.\n */\nCell.prototype.draw = function (lineNum, spanningCell) {\n if (lineNum == 'top') return this.drawTop(this.drawRight);\n if (lineNum == 'bottom') return this.drawBottom(this.drawRight);\n var padLen = Math.max(this.height - this.lines.length, 0);\n var padTop;\n switch (this.vAlign) {\n case 'center':\n padTop = Math.ceil(padLen / 2);\n break;\n case 'bottom':\n padTop = padLen;\n break;\n default:\n padTop = 0;\n }\n if (lineNum < padTop || lineNum >= padTop + this.lines.length) {\n return this.drawEmpty(this.drawRight, spanningCell);\n }\n var forceTruncation = this.lines.length > this.height && lineNum + 1 >= this.height;\n return this.drawLine(lineNum - padTop, this.drawRight, forceTruncation, spanningCell);\n};\n\n/**\n * Renders the top line of the cell.\n * @param drawRight - true if this method should render the right edge of the cell.\n * @returns {String}\n */\nCell.prototype.drawTop = function (drawRight) {\n var content = [];\n if (this.cells) {\n //TODO: cells should always exist - some tests don't fill it in though\n _.forEach(this.widths, function (width, index) {\n content.push(this._topLeftChar(index));\n content.push(utils.repeat(this.chars[this.y == 0 ? 'top' : 'mid'], width));\n }, this);\n } else {\n content.push(this._topLeftChar(0));\n content.push(utils.repeat(this.chars[this.y == 0 ? 'top' : 'mid'], this.width));\n }\n if (drawRight) {\n content.push(this.chars[this.y == 0 ? 'topRight' : 'rightMid']);\n }\n return this.wrapWithStyleColors('border', content.join(''));\n};\n\nCell.prototype._topLeftChar = function (offset) {\n var x = this.x + offset;\n var leftChar;\n if (this.y == 0) {\n leftChar = x == 0 ? 'topLeft' : offset == 0 ? 'topMid' : 'top';\n } else {\n if (x == 0) {\n leftChar = 'leftMid';\n } else {\n leftChar = offset == 0 ? 'midMid' : 'bottomMid';\n if (this.cells) {\n //TODO: cells should always exist - some tests don't fill it in though\n var spanAbove = this.cells[this.y - 1][x] instanceof Cell.ColSpanCell;\n if (spanAbove) {\n leftChar = offset == 0 ? 'topMid' : 'mid';\n }\n if (offset == 0) {\n var i = 1;\n while (this.cells[this.y][x - i] instanceof Cell.ColSpanCell) {\n i++;\n }\n if (this.cells[this.y][x - i] instanceof Cell.RowSpanCell) {\n leftChar = 'leftMid';\n }\n }\n }\n }\n }\n return this.chars[leftChar];\n};\n\nCell.prototype.wrapWithStyleColors = function (styleProperty, content) {\n if (this[styleProperty] && this[styleProperty].length) {\n try {\n var colors = require('colors/safe');\n for (var i = this[styleProperty].length - 1; i >= 0; i--) {\n colors = colors[this[styleProperty][i]];\n }\n return colors(content);\n } catch (e) {\n return content;\n }\n } else {\n return content;\n }\n};\n\n/**\n * Renders a line of text.\n * @param lineNum - Which line of text to render. This is not necessarily the line within the cell.\n * There may be top-padding above the first line of text.\n * @param drawRight - true if this method should render the right edge of the cell.\n * @param forceTruncationSymbol - `true` if the rendered text should end with the truncation symbol even\n * if the text fits. This is used when the cell is vertically truncated. If `false` the text should\n * only include the truncation symbol if the text will not fit horizontally within the cell width.\n * @param spanningCell - a number of if being called from a RowSpanCell. (how many rows below). otherwise undefined.\n * @returns {String}\n */\nCell.prototype.drawLine = function (lineNum, drawRight, forceTruncationSymbol, spanningCell) {\n var left = this.chars[this.x == 0 ? 'left' : 'middle'];\n if (this.x && spanningCell && this.cells) {\n var cellLeft = this.cells[this.y + spanningCell][this.x - 1];\n while (cellLeft instanceof ColSpanCell) {\n cellLeft = this.cells[cellLeft.y][cellLeft.x - 1];\n }\n if (!(cellLeft instanceof RowSpanCell)) {\n left = this.chars['rightMid'];\n }\n }\n var leftPadding = utils.repeat(' ', this.paddingLeft);\n var right = drawRight ? this.chars['right'] : '';\n var rightPadding = utils.repeat(' ', this.paddingRight);\n var line = this.lines[lineNum];\n var len = this.width - (this.paddingLeft + this.paddingRight);\n if (forceTruncationSymbol) line += this.truncate || '…';\n var content = utils.truncate(line, len, this.truncate);\n content = utils.pad(content, len, ' ', this.hAlign);\n content = leftPadding + content + rightPadding;\n return this.stylizeLine(left, content, right);\n};\n\nCell.prototype.stylizeLine = function (left, content, right) {\n left = this.wrapWithStyleColors('border', left);\n right = this.wrapWithStyleColors('border', right);\n if (this.y === 0) {\n content = this.wrapWithStyleColors('head', content);\n }\n return left + content + right;\n};\n\n/**\n * Renders the bottom line of the cell.\n * @param drawRight - true if this method should render the right edge of the cell.\n * @returns {String}\n */\nCell.prototype.drawBottom = function (drawRight) {\n var left = this.chars[this.x == 0 ? 'bottomLeft' : 'bottomMid'];\n var content = utils.repeat(this.chars.bottom, this.width);\n var right = drawRight ? this.chars['bottomRight'] : '';\n return this.wrapWithStyleColors('border', left + content + right);\n};\n\n/**\n * Renders a blank line of text within the cell. Used for top and/or bottom padding.\n * @param drawRight - true if this method should render the right edge of the cell.\n * @param spanningCell - a number of if being called from a RowSpanCell. (how many rows below). otherwise undefined.\n * @returns {String}\n */\nCell.prototype.drawEmpty = function (drawRight, spanningCell) {\n var left = this.chars[this.x == 0 ? 'left' : 'middle'];\n if (this.x && spanningCell && this.cells) {\n var cellLeft = this.cells[this.y + spanningCell][this.x - 1];\n while (cellLeft instanceof ColSpanCell) {\n cellLeft = this.cells[cellLeft.y][cellLeft.x - 1];\n }\n if (!(cellLeft instanceof RowSpanCell)) {\n left = this.chars['rightMid'];\n }\n }\n var right = drawRight ? this.chars['right'] : '';\n var content = utils.repeat(' ', this.width);\n return this.stylizeLine(left, content, right);\n};\n\n/**\n * A Cell that doesn't do anything. It just draws empty lines.\n * Used as a placeholder in column spanning.\n * @constructor\n */\nfunction ColSpanCell() {}\n\nColSpanCell.prototype.draw = function () {\n return '';\n};\n\nColSpanCell.prototype.init = function (tableOptions) {};\n\n/**\n * A placeholder Cell for a Cell that spans multiple rows.\n * It delegates rendering to the original cell, but adds the appropriate offset.\n * @param originalCell\n * @constructor\n */\nfunction RowSpanCell(originalCell) {\n this.originalCell = originalCell;\n}\n\nRowSpanCell.prototype.init = function (tableOptions) {\n var y = this.y;\n var originalY = this.originalCell.y;\n this.cellOffset = y - originalY;\n this.offset = findDimension(tableOptions.rowHeights, originalY, this.cellOffset);\n};\n\nRowSpanCell.prototype.draw = function (lineNum) {\n if (lineNum == 'top') {\n return this.originalCell.draw(this.offset, this.cellOffset);\n }\n if (lineNum == 'bottom') {\n return this.originalCell.draw('bottom');\n }\n return this.originalCell.draw(this.offset + 1 + lineNum);\n};\n\nColSpanCell.prototype.mergeTableOptions = RowSpanCell.prototype.mergeTableOptions = function () {};\n\n// HELPER FUNCTIONS\nfunction setOption(objA, objB, nameB, targetObj) {\n var nameA = nameB.split('-');\n if (nameA.length > 1) {\n nameA[1] = nameA[1].charAt(0).toUpperCase() + nameA[1].substr(1);\n nameA = nameA.join('');\n targetObj[nameA] = objA[nameA] || objA[nameB] || objB[nameA] || objB[nameB];\n } else {\n targetObj[nameB] = objA[nameB] || objB[nameB];\n }\n}\n\nfunction findDimension(dimensionTable, startingIndex, span) {\n var ret = dimensionTable[startingIndex];\n for (var i = 1; i < span; i++) {\n ret += 1 + dimensionTable[startingIndex + i];\n }\n return ret;\n}\n\nfunction sumPlusOne(a, b) {\n return a + b + 1;\n}\n\nvar CHAR_NAMES = ['top', 'top-mid', 'top-left', 'top-right', 'bottom', 'bottom-mid', 'bottom-left', 'bottom-right', 'left', 'left-mid', 'mid', 'mid-mid', 'right', 'right-mid', 'middle'];\nmodule.exports = Cell;\nmodule.exports.ColSpanCell = ColSpanCell;\nmodule.exports.RowSpanCell = RowSpanCell;",{"version":3,"sources":["node_modules/cli-table2/src/cell.js"],"names":["_","require","utils","Cell","options","setOptions","prototype","isString","isNumber","isBoolean","content","String","Error","colSpan","rowSpan","mergeTableOptions","tableOptions","cells","optionsChars","chars","tableChars","forEach","CHAR_NAMES","name","setOption","truncate","style","tableStyle","head","border","fixedWidth","colWidths","x","wordWrap","paddingLeft","paddingRight","lines","colorizeLines","split","desiredWidth","strlen","desiredHeight","length","y","init","widths","slice","heights","rowHeights","width","reduce","sumPlusOne","height","hAlign","colAligns","vAlign","rowAligns","drawRight","draw","lineNum","spanningCell","drawTop","drawBottom","padLen","Math","max","padTop","ceil","drawEmpty","forceTruncation","drawLine","index","push","_topLeftChar","repeat","wrapWithStyleColors","join","offset","leftChar","spanAbove","ColSpanCell","i","RowSpanCell","styleProperty","colors","e","forceTruncationSymbol","left","cellLeft","leftPadding","right","rightPadding","line","len","pad","stylizeLine","bottom","originalCell","originalY","cellOffset","findDimension","objA","objB","nameB","targetObj","nameA","charAt","toUpperCase","substr","dimensionTable","startingIndex","span","ret","a","b","module","exports"],"mappings":";;;;AAAA,IAAIA,IAAIC,QAAQ,QAAR,CAAR;AACA,IAAIC,QAAQD,QAAQ,SAAR,CAAZ;;AAEA;;;;;;;AAOA,SAASE,IAAT,CAAcC,OAAd,EAAsB;AACpB,OAAKC,UAAL,CAAgBD,OAAhB;AACD;;AAEDD,KAAKG,SAAL,CAAeD,UAAf,GAA4B,UAASD,OAAT,EAAiB;AAC3C,MAAGJ,EAAEO,QAAF,CAAWH,OAAX,KAAuBJ,EAAEQ,QAAF,CAAWJ,OAAX,CAAvB,IAA8CJ,EAAES,SAAF,CAAYL,OAAZ,CAAjD,EAAsE;AACpEA,cAAU,EAACM,SAAQ,KAAGN,OAAZ,EAAV;AACD;AACDA,YAAUA,WAAW,EAArB;AACA,OAAKA,OAAL,GAAeA,OAAf;AACA,MAAIM,UAAUN,QAAQM,OAAtB;AACA,MAAIV,EAAEO,QAAF,CAAWG,OAAX,KAAuBV,EAAEQ,QAAF,CAAWE,OAAX,CAAvB,IAA8CV,EAAES,SAAF,CAAYC,OAAZ,CAAlD,EAAwE;AACtE,SAAKA,OAAL,GAAeC,OAAOD,OAAP,CAAf;AACD,GAFD,MAEO,IAAI,CAACA,OAAL,EAAc;AACnB,SAAKA,OAAL,GAAe,EAAf;AACD,GAFM,MAEA;AACL,UAAM,IAAIE,KAAJ,CAAU,mDAAoDF,OAApD,yCAAoDA,OAApD,EAAV,CAAN;AACD;AACD,OAAKG,OAAL,GAAeT,QAAQS,OAAR,IAAmB,CAAlC;AACA,OAAKC,OAAL,GAAeV,QAAQU,OAAR,IAAmB,CAAlC;AACD,CAhBD;;AAkBAX,KAAKG,SAAL,CAAeS,iBAAf,GAAmC,UAASC,YAAT,EAAsBC,KAAtB,EAA4B;AAC7D,OAAKA,KAAL,GAAaA,KAAb;;AAEA,MAAIC,eAAe,KAAKd,OAAL,CAAae,KAA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A7B;AACAmC,OAAOC,OAAP,CAAelC,WAAf,GAA6BA,WAA7B","file":"cell.js","sourceRoot":"/data","sourcesContent":["var _ = require('lodash');\nvar utils = require('./utils');\n\n/**\n * A representation of a cell within the table.\n * Implementations must have `init` and `draw` methods,\n * as well as `colSpan`, `rowSpan`, `desiredHeight` and `desiredWidth` properties.\n * @param options\n * @constructor\n */\nfunction Cell(options){\n this.setOptions(options);\n}\n\nCell.prototype.setOptions = function(options){\n if(_.isString(options) || _.isNumber(options) || _.isBoolean(options)){\n options = {content:''+options};\n }\n options = options || {};\n this.options = options;\n var content = options.content;\n if (_.isString(content) || _.isNumber(content) || _.isBoolean(content)) {\n this.content = String(content);\n } else if (!content) {\n this.content = '';\n } else {\n throw new Error('Content needs to be a primitive, got: ' + (typeof content));\n }\n this.colSpan = options.colSpan || 1;\n this.rowSpan = options.rowSpan || 1;\n};\n\nCell.prototype.mergeTableOptions = function(tableOptions,cells){\n this.cells = cells;\n\n var optionsChars = this.options.chars || {};\n var tableChars = tableOptions.chars;\n var chars = this.chars = {};\n _.forEach(CHAR_NAMES,function(name){\n setOption(optionsChars,tableChars,name,chars);\n });\n\n this.truncate = this.options.truncate || tableOptions.truncate;\n\n var style = this.options.style = this.options.style || {};\n var tableStyle = tableOptions.style;\n setOption(style, tableStyle, 'padding-left', this);\n setOption(style, tableStyle, 'padding-right', this);\n this.head = style.head || tableStyle.head;\n this.border = style.border || tableStyle.border;\n\n var fixedWidth = tableOptions.colWidths[this.x];\n if(tableOptions.wordWrap && fixedWidth){\n fixedWidth -= this.paddingLeft + this.paddingRight;\n this.lines = utils.colorizeLines(utils.wordWrap(fixedWidth,this.content));\n }\n else {\n this.lines = utils.colorizeLines(this.content.split('\\n'));\n }\n\n this.desiredWidth = utils.strlen(this.content) + this.paddingLeft + this.paddingRight;\n this.desiredHeight = this.lines.length;\n};\n\n/**\n * Each cell will have it's `x` and `y` values set by the `layout-manager` prior to\n * `init` being called;\n * @type {Number}\n */\n\nCell.prototype.x = null;\nCell.prototype.y = null;\n\n/**\n * Initializes the Cells data structure.\n *\n * @param tableOptions - A fully populated set of tableOptions.\n * In addition to the standard default values, tableOptions must have fully populated the\n * `colWidths` and `rowWidths` arrays. Those arrays must have lengths equal to the number\n * of columns or rows (respectively) in this table, and each array item must be a Number.\n *\n */\nCell.prototype.init = function(tableOptions){\n var x = this.x;\n var y = this.y;\n this.widths = tableOptions.colWidths.slice(x, x + this.colSpan);\n this.heights = tableOptions.rowHeights.slice(y, y + this.rowSpan);\n this.width = _.reduce(this.widths,sumPlusOne);\n this.height = _.reduce(this.heights,sumPlusOne);\n\n this.hAlign = this.options.hAlign || tableOptions.colAligns[x];\n this.vAlign = this.options.vAlign || tableOptions.rowAligns[y];\n\n this.drawRight = x + this.colSpan == tableOptions.colWidths.length;\n};\n\n/**\n * Draws the given line of the cell.\n * This default implementation defers to methods `drawTop`, `drawBottom`, `drawLine` and `drawEmpty`.\n * @param lineNum - can be `top`, `bottom` or a numerical line number.\n * @param spanningCell - will be a number if being called from a RowSpanCell, and will represent how\n * many rows below it's being called from. Otherwise it's undefined.\n * @returns {String} The representation of this line.\n */\nCell.prototype.draw = function(lineNum,spanningCell){\n if(lineNum == 'top') return this.drawTop(this.drawRight);\n if(lineNum == 'bottom') return this.drawBottom(this.drawRight);\n var padLen = Math.max(this.height - this.lines.length, 0);\n var padTop;\n switch (this.vAlign){\n case 'center':\n padTop = Math.ceil(padLen / 2);\n break;\n case 'bottom':\n padTop = padLen;\n break;\n default :\n padTop = 0;\n }\n if( (lineNum < padTop) || (lineNum >= (padTop + this.lines.length))){\n return this.drawEmpty(this.drawRight,spanningCell);\n }\n var forceTruncation = (this.lines.length > this.height) && (lineNum + 1 >= this.height);\n return this.drawLine(lineNum - padTop, this.drawRight, forceTruncation,spanningCell);\n};\n\n/**\n * Renders the top line of the cell.\n * @param drawRight - true if this method should render the right edge of the cell.\n * @returns {String}\n */\nCell.prototype.drawTop = function(drawRight){\n var content = [];\n if(this.cells){ //TODO: cells should always exist - some tests don't fill it in though\n _.forEach(this.widths,function(width,index){\n content.push(this._topLeftChar(index));\n content.push(\n utils.repeat(this.chars[this.y == 0 ? 'top' : 'mid'],width)\n );\n },this);\n }\n else {\n content.push(this._topLeftChar(0));\n content.push(utils.repeat(this.chars[this.y == 0 ? 'top' : 'mid'],this.width));\n }\n if(drawRight){\n content.push(this.chars[this.y == 0 ? 'topRight' : 'rightMid']);\n }\n return this.wrapWithStyleColors('border',content.join(''));\n};\n\nCell.prototype._topLeftChar = function(offset){\n var x = this.x+offset;\n var leftChar;\n if(this.y == 0){\n leftChar = x == 0 ? 'topLeft' : (offset == 0 ? 'topMid' : 'top');\n } else {\n if(x == 0){\n leftChar = 'leftMid';\n }\n else {\n leftChar = offset == 0 ? 'midMid' : 'bottomMid';\n if(this.cells){ //TODO: cells should always exist - some tests don't fill it in though\n var spanAbove = this.cells[this.y-1][x] instanceof Cell.ColSpanCell;\n if(spanAbove){\n leftChar = offset == 0 ? 'topMid' : 'mid';\n }\n if(offset == 0){\n var i = 1;\n while(this.cells[this.y][x-i] instanceof Cell.ColSpanCell){\n i++;\n }\n if(this.cells[this.y][x-i] instanceof Cell.RowSpanCell){\n leftChar = 'leftMid';\n }\n }\n }\n }\n }\n return this.chars[leftChar];\n};\n\nCell.prototype.wrapWithStyleColors = function(styleProperty,content){\n if(this[styleProperty] && this[styleProperty].length){\n try {\n var colors = require('colors/safe');\n for(var i = this[styleProperty].length - 1; i >= 0; i--){\n colors = colors[this[styleProperty][i]];\n }\n return colors(content);\n } catch (e) {\n return content;\n }\n }\n else {\n return content;\n }\n};\n\n/**\n * Renders a line of text.\n * @param lineNum - Which line of text to render. This is not necessarily the line within the cell.\n * There may be top-padding above the first line of text.\n * @param drawRight - true if this method should render the right edge of the cell.\n * @param forceTruncationSymbol - `true` if the rendered text should end with the truncation symbol even\n * if the text fits. This is used when the cell is vertically truncated. If `false` the text should\n * only include the truncation symbol if the text will not fit horizontally within the cell width.\n * @param spanningCell - a number of if being called from a RowSpanCell. (how many rows below). otherwise undefined.\n * @returns {String}\n */\nCell.prototype.drawLine = function(lineNum,drawRight,forceTruncationSymbol,spanningCell){\n var left = this.chars[this.x == 0 ? 'left' : 'middle'];\n if(this.x && spanningCell && this.cells){\n var cellLeft = this.cells[this.y+spanningCell][this.x-1];\n while(cellLeft instanceof ColSpanCell){\n cellLeft = this.cells[cellLeft.y][cellLeft.x-1];\n }\n if(!(cellLeft instanceof RowSpanCell)){\n left = this.chars['rightMid'];\n }\n }\n var leftPadding = utils.repeat(' ', this.paddingLeft);\n var right = (drawRight ? this.chars['right'] : '');\n var rightPadding = utils.repeat(' ', this.paddingRight);\n var line = this.lines[lineNum];\n var len = this.width - (this.paddingLeft + this.paddingRight);\n if(forceTruncationSymbol) line += this.truncate || '…';\n var content = utils.truncate(line,len,this.truncate);\n content = utils.pad(content, len, ' ', this.hAlign);\n content = leftPadding + content + rightPadding;\n return this.stylizeLine(left,content,right);\n};\n\nCell.prototype.stylizeLine = function(left,content,right){\n left = this.wrapWithStyleColors('border',left);\n right = this.wrapWithStyleColors('border',right);\n if(this.y === 0){\n content = this.wrapWithStyleColors('head',content);\n }\n return left + content + right;\n};\n\n/**\n * Renders the bottom line of the cell.\n * @param drawRight - true if this method should render the right edge of the cell.\n * @returns {String}\n */\nCell.prototype.drawBottom = function(drawRight){\n var left = this.chars[this.x == 0 ? 'bottomLeft' : 'bottomMid'];\n var content = utils.repeat(this.chars.bottom,this.width);\n var right = drawRight ? this.chars['bottomRight'] : '';\n return this.wrapWithStyleColors('border',left + content + right);\n};\n\n/**\n * Renders a blank line of text within the cell. Used for top and/or bottom padding.\n * @param drawRight - true if this method should render the right edge of the cell.\n * @param spanningCell - a number of if being called from a RowSpanCell. (how many rows below). otherwise undefined.\n * @returns {String}\n */\nCell.prototype.drawEmpty = function(drawRight,spanningCell){\n var left = this.chars[this.x == 0 ? 'left' : 'middle'];\n if(this.x && spanningCell && this.cells){\n var cellLeft = this.cells[this.y+spanningCell][this.x-1];\n while(cellLeft instanceof ColSpanCell){\n cellLeft = this.cells[cellLeft.y][cellLeft.x-1];\n }\n if(!(cellLeft instanceof RowSpanCell)){\n left = this.chars['rightMid'];\n }\n }\n var right = (drawRight ? this.chars['right'] : '');\n var content = utils.repeat(' ',this.width);\n return this.stylizeLine(left , content , right);\n};\n\n/**\n * A Cell that doesn't do anything. It just draws empty lines.\n * Used as a placeholder in column spanning.\n * @constructor\n */\nfunction ColSpanCell(){}\n\nColSpanCell.prototype.draw = function(){\n return '';\n};\n\nColSpanCell.prototype.init = function(tableOptions){};\n\n\n/**\n * A placeholder Cell for a Cell that spans multiple rows.\n * It delegates rendering to the original cell, but adds the appropriate offset.\n * @param originalCell\n * @constructor\n */\nfunction RowSpanCell(originalCell){\n this.originalCell = originalCell;\n}\n\nRowSpanCell.prototype.init = function(tableOptions){\n var y = this.y;\n var originalY = this.originalCell.y;\n this.cellOffset = y - originalY;\n this.offset = findDimension(tableOptions.rowHeights,originalY,this.cellOffset);\n};\n\nRowSpanCell.prototype.draw = function(lineNum){\n if(lineNum == 'top'){\n return this.originalCell.draw(this.offset,this.cellOffset);\n }\n if(lineNum == 'bottom'){\n return this.originalCell.draw('bottom');\n }\n return this.originalCell.draw(this.offset + 1 + lineNum);\n};\n\nColSpanCell.prototype.mergeTableOptions =\nRowSpanCell.prototype.mergeTableOptions = function(){};\n\n// HELPER FUNCTIONS\nfunction setOption(objA,objB,nameB,targetObj){\n var nameA = nameB.split('-');\n if(nameA.length > 1) {\n nameA[1] = nameA[1].charAt(0).toUpperCase() + nameA[1].substr(1);\n nameA = nameA.join('');\n targetObj[nameA] = objA[nameA] || objA[nameB] || objB[nameA] || objB[nameB];\n }\n else {\n targetObj[nameB] = objA[nameB] || objB[nameB];\n }\n}\n\nfunction findDimension(dimensionTable, startingIndex, span){\n var ret = dimensionTable[startingIndex];\n for(var i = 1; i < span; i++){\n ret += 1 + dimensionTable[startingIndex + i];\n }\n return ret;\n}\n\nfunction sumPlusOne(a,b){\n return a+b+1;\n}\n\nvar CHAR_NAMES = [ 'top'\n , 'top-mid'\n , 'top-left'\n , 'top-right'\n , 'bottom'\n , 'bottom-mid'\n , 'bottom-left'\n , 'bottom-right'\n , 'left'\n , 'left-mid'\n , 'mid'\n , 'mid-mid'\n , 'right'\n , 'right-mid'\n , 'middle'\n];\nmodule.exports = Cell;\nmodule.exports.ColSpanCell = ColSpanCell;\nmodule.exports.RowSpanCell = RowSpanCell;"]}]}