Vous ne pouvez pas sélectionner plus de 25 sujets Les noms de sujets doivent commencer par une lettre ou un nombre, peuvent contenir des tirets ('-') et peuvent comporter jusqu'à 35 caractères.

calculateMaximumColumnWidthIndex.js 923 B

il y a 3 ans
12345678910111213141516171819202122232425262728293031323334353637
  1. 'use strict';
  2. Object.defineProperty(exports, "__esModule", {
  3. value: true
  4. });
  5. var _calculateCellWidthIndex = require('./calculateCellWidthIndex');
  6. var _calculateCellWidthIndex2 = _interopRequireDefault(_calculateCellWidthIndex);
  7. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  8. /**
  9. * Produces an array of values that describe the largest value length (width) in every column.
  10. *
  11. * @param {Array[]} rows
  12. * @returns {number[]}
  13. */
  14. exports.default = rows => {
  15. if (!rows[0]) {
  16. throw new Error('Dataset must have at least one row.');
  17. }
  18. const columns = Array(rows[0].length).fill(0);
  19. rows.forEach(row => {
  20. const columnWidthIndex = (0, _calculateCellWidthIndex2.default)(row);
  21. columnWidthIndex.forEach((valueWidth, index0) => {
  22. if (columns[index0] < valueWidth) {
  23. columns[index0] = valueWidth;
  24. }
  25. });
  26. });
  27. return columns;
  28. };