calculateCellWidthIndex.js 689 Bytes
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28
"use strict";

Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.default = void 0;

var _stringWidth = _interopRequireDefault(require("string-width"));

function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }

/**
 * Calculates width of each cell contents.
 *
 * @param {string[]} cells
 * @returns {number[]}
 */
const calculateCellWidthIndex = cells => {
  return cells.map(value => {
    return Math.max(...value.split('\n').map(line => {
      return (0, _stringWidth.default)(line);
    }));
  });
};

var _default = calculateCellWidthIndex;
exports.default = _default;
//# sourceMappingURL=calculateCellWidthIndex.js.map