You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

37 lines
1013 B

4 years ago
  1. "use strict";
  2. Object.defineProperty(exports, "__esModule", {
  3. value: true
  4. });
  5. exports.default = void 0;
  6. var _isString2 = _interopRequireDefault(require("lodash/isString"));
  7. var _wrapCell = _interopRequireDefault(require("./wrapCell"));
  8. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  9. /**
  10. * @param {string} value
  11. * @param {number} columnWidth
  12. * @param {boolean} useWrapWord
  13. * @returns {number}
  14. */
  15. const calculateCellHeight = (value, columnWidth, useWrapWord = false) => {
  16. if (!(0, _isString2.default)(value)) {
  17. throw new TypeError('Value must be a string.');
  18. }
  19. if (!Number.isInteger(columnWidth)) {
  20. throw new TypeError('Column width must be an integer.');
  21. }
  22. if (columnWidth < 1) {
  23. throw new Error('Column width must be greater than 0.');
  24. }
  25. return (0, _wrapCell.default)(value, columnWidth, useWrapWord).length;
  26. };
  27. var _default = calculateCellHeight;
  28. exports.default = _default;
  29. //# sourceMappingURL=calculateCellHeight.js.map