1import _ from 'lodash'; 2import wrapCell from './wrapCell'; 3 4/** 5 * @param {string} value 6 * @param {number} columnWidth 7 * @param {boolean} useWrapWord 8 * @returns {number} 9 */ 10export default (value, columnWidth, useWrapWord = false) => { 11 if (!_.isString(value)) { 12 throw new TypeError('Value must be a string.'); 13 } 14 15 if (!Number.isInteger(columnWidth)) { 16 throw new TypeError('Column width must be an integer.'); 17 } 18 19 if (columnWidth < 1) { 20 throw new Error('Column width must be greater than 0.'); 21 } 22 23 return wrapCell(value, columnWidth, useWrapWord).length; 24}; 25