index.js
function createRows(items, columns, columnNames, paddingChr) {
  return items.map(item => {
    let row = []
    let numLines = 0
    columnNames.forEach(columnName => {
      numLines = Math.max(numLines, item[columnName].length)
    })
    // combine matching lines of each rows
    for (let i = 0; i < numLines; i++) {
      row[i] = row[i] || []
      columnNames.forEach(columnName => {
        let column = columns[columnName]
        let val = item[columnName][i] || '' // || '' ensures empty columns get padded
        if (column.align === 'right') row[i].push(padLeft(val, column.width, paddingChr))
        else if (column.align === 'center' || column.align === 'centre') row[i].push(padCenter(val, column.width, paddingChr))
        else row[i].push(padRight(val, column.width, paddingChr))
      })
    }
    return row
  })
}
function createRows(items, columns, columnNames, paddingChr) {
  return items.map(item => {
    let row = []
    let numLines = 0
    columnNames.forEach(columnName => {
      numLines = Math.max(numLines, item[columnName].length)
    })
    // combine matching lines of each rows
    for (let i = 0; i < numLines; i++) {
      row[i] = row[i] || []
      columnNames.forEach(columnName => {
        let column = columns[columnName]
        let val = item[columnName][i] || '' // || '' ensures empty columns get padded
        if (column.align === 'right') row[i].push(padLeft(val, column.width, paddingChr))
        else if (column.align === 'center' || column.align === 'centre') row[i].push(padCenter(val, column.width, paddingChr))
        else row[i].push(padRight(val, column.width, paddingChr))
      })
    }
    return row
  })
}
function createRows ( items , columns , columnNames , paddingChr ) { return items . map ( item => { let row = [ ] let numLines = 0 columnNames . forEach ( columnName => { numLines = Math . max ( numLines , item [ columnName ] . length ) } ) // combine matching lines of each rows for ( let i = 0 ; i < numLines ; i ++ ) { row [ i ] = row [ i ] || [ ] columnNames . forEach ( columnName => { let column = columns [ columnName ] let val = item [ columnName ] [ i ] || '' // || '' ensures empty columns get padded if ( column . align === 'right' ) row [ i ] . push ( padLeft ( val , column . width , paddingChr ) ) else if ( column . align === 'center' || column . align === 'centre' ) row [ i ] . push ( padCenter ( val , column . width , paddingChr ) ) else row [ i ] . push ( padRight ( val , column . width , paddingChr ) ) } ) } return row } ) }
Convert wrapped lines into rows with padded values.

@param Array items data to process
@param Array columns column width settings for wrapping
@param Array columnNames column ordering
@return Array items wrapped in arrays, corresponding to lines
Convert wrapped lines into rows with padded values .