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.

17 lines
328 B

4 years ago
  1. import stringWidth from 'string-width';
  2. /**
  3. * Calculates width of each cell contents.
  4. *
  5. * @param {string[]} cells
  6. * @returns {number[]}
  7. */
  8. export default (cells) => {
  9. return cells.map((value) => {
  10. return Math.max(
  11. ...value.split('\n').map((line) => {
  12. return stringWidth(line);
  13. })
  14. );
  15. });
  16. };