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.

21 lines
503 B

4 years ago
  1. import stringWidth from 'string-width';
  2. import alignString from './alignString';
  3. /**
  4. * @param {table~row[]} rows
  5. * @param {Object} config
  6. * @returns {table~row[]}
  7. */
  8. export default (rows, config) => {
  9. return rows.map((cells) => {
  10. return cells.map((value, index1) => {
  11. const column = config.columns[index1];
  12. if (stringWidth(value) === column.width) {
  13. return value;
  14. } else {
  15. return alignString(value, column.width, column.alignment);
  16. }
  17. });
  18. });
  19. };