lib/formatters.js
function TableFormatter(options) {
  const table = new Table(options);
  this.format = format;
  function format(result, formatOptions) {
    let data = [];
    _.each(result, function (item) {
      data.push(_.values(_.pick(item, options.values)));
    });
    if (formatOptions.format === 'csv') {
     _.each(data, function(row) {
       console.log(row.join(','));
     });
    } else if ( formatOptions.format === 'json') {
      console.log(JSON.stringify(result));
    } else {
      table.push.apply(table, data);
      console.log(table.toString());
    }
  }
}
function TableFormatter(options) {
  const table = new Table(options);
  this.format = format;
  function format(result, formatOptions) {
    let data = [];
    _.each(result, function (item) {
      data.push(_.values(_.pick(item, options.values)));
    });
    if (formatOptions.format === 'csv') {
     _.each(data, function(row) {
       console.log(row.join(','));
     });
    } else if ( formatOptions.format === 'json') {
      console.log(JSON.stringify(result));
    } else {
      table.push.apply(table, data);
      console.log(table.toString());
    }
  }
}
function TableFormatter ( options ) { const table = new Table ( options ) ; this . format = format ; function format ( result , formatOptions ) { let data = [ ] ; _ . each ( result , function ( item ) { data . push ( _ . values ( _ . pick ( item , options . values ) ) ) ; } ) ; if ( formatOptions . format === 'csv' ) { _ . each ( data , function ( row ) { console . log ( row . join ( ',' ) ) ; } ) ; } else if ( formatOptions . format === 'json' ) { console . log ( JSON . stringify ( result ) ) ; } else { table . push . apply ( table , data ) ; console . log ( table . toString ( ) ) ; } } }
Formatter to output tabular data
@param options
@constructor
Formatter to output tabular data