{"size": 2473, "ext": "js", "max_stars_repo_path": "node.org/demo1/node_modules/standard/node_modules/eslint/node_modules/table/dist/mapDataUsingRowHeightIndex.js", "max_stars_repo_name": "chimywang/learning_node", "max_stars_repo_stars_event_min_datetime": "2015-08-12T06:56:25.000Z", "max_stars_repo_stars_event_max_datetime": "2022-03-11T03:02:48.000Z", "max_issues_repo_path": "node.org/demo1/node_modules/standard/node_modules/eslint/node_modules/table/dist/mapDataUsingRowHeightIndex.js", "max_issues_repo_name": "chimywang/learning_node", "max_issues_repo_issues_event_min_datetime": "2015-03-26T18:58:36.000Z", "max_issues_repo_issues_event_max_datetime": "2021-06-13T06:42:12.000Z", "max_forks_repo_path": "node.org/demo1/node_modules/standard/node_modules/eslint/node_modules/table/dist/mapDataUsingRowHeightIndex.js", "max_forks_repo_name": "chimywang/learning_node", "max_forks_repo_forks_event_min_datetime": "2015-01-15T08:26:25.000Z", "max_forks_repo_forks_event_max_datetime": "2022-03-28T03:34:39.000Z"}
{"max_stars_count": 29, "max_issues_count": 3, "max_forks_count": 120, "avg_line_length": 28.4252873563, "max_line_length": 127, "alphanum_fraction": 0.6465830975}
'use strict';

Object.defineProperty(exports, "__esModule", {
    value: true
});

var _flatten2 = require('lodash/flatten');

var _flatten3 = _interopRequireDefault(_flatten2);

var _forEach2 = require('lodash/forEach');

var _forEach3 = _interopRequireDefault(_forEach2);

var _fill2 = require('lodash/fill');

var _fill3 = _interopRequireDefault(_fill2);

var _map2 = require('lodash/map');

var _map3 = _interopRequireDefault(_map2);

var _wrapString = require('./wrapString');

var _wrapString2 = _interopRequireDefault(_wrapString);

var _wrapWord = require('./wrapWord');

var _wrapWord2 = _interopRequireDefault(_wrapWord);

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

/**
 * @param {Array} unmappedRows
 * @param {number[]} rowHeightIndex
 * @param {Object} config
 * @return {Array}
 */

exports.default = function (unmappedRows, rowHeightIndex, config) {
    var mappedRows = undefined,
        tableWidth = undefined;

    tableWidth = unmappedRows[0].length;

    // console.log('unmappedRows', unmappedRows, 'rowHeightIndex', rowHeightIndex, 'config', config, 'tableWidth', tableWidth);

    mappedRows = (0, _map3.default)(unmappedRows, function (cells, index0) {
        var rowHeight = undefined;

        rowHeight = (0, _map3.default)(Array(rowHeightIndex[index0]), function () {
            return (0, _fill3.default)(Array(tableWidth), '');
        });

        // console.log('rowHeight', rowHeight);

        // rowHeight
        //     [{row index within rowSaw; index2}]
        //     [{cell index within a virtual row; index1}]

        (0, _forEach3.default)(cells, function (value, index1) {
            var chunkedValue = undefined;

            if (config.columns[index1].wrapWord) {
                chunkedValue = (0, _wrapWord2.default)(value, config.columns[index1].width);
            } else {
                chunkedValue = (0, _wrapString2.default)(value, config.columns[index1].width);
            }

            // console.log('chunkedValue', chunkedValue.length, 'rowHeight', rowHeight.length);

            (0, _forEach3.default)(chunkedValue, function (part, index2) {
                // console.log(rowHeight[index2]);

                rowHeight[index2][index1] = part;
            });
        });

        return rowHeight;
    });

    return (0, _flatten3.default)(mappedRows);
};

module.exports = exports['default'];
//# sourceMappingURL=mapDataUsingRowHeightIndex.js.map
