42cb220cfc9c8d9b36af50034460b9667895fac5de083b2dc141bf3fd8cccc0b475f3d6d74824ad691b6fafb29168cc6922ea04ef620e68cd148102753ea1a 328 B

1234567891011121314151617
  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. };