Skip to content

Latest commit

 

History

History
77 lines (58 loc) · 3.65 KB

API.md

File metadata and controls

77 lines (58 loc) · 3.65 KB

table-layout

Table ⏏

Recordset data in (array of objects), text table out.

Kind: Exported class

new Table(data, [options])

Params

  • data Array.<object> - input data
  • [options] object - optional settings
    • [.maxWidth] number - maximum width of layout
    • [.noWrap] boolean - disable wrapping on all columns
    • [.noTrim] boolean - disable line-trimming
    • [.break] boolean - enable word-breaking on all columns
    • [.columns] columnOption - array of column-specific options
    • [.ignoreEmptyColumns] boolean - If set, empty columns or columns containing only whitespace are not rendered.
    • [.padding] object - Padding values to set on each column. Per-column overrides can be set in the options.columns array.
      • [.left] string - Defaults to a single space.
      • [.right] string - Defaults to a single space.
    • [.eol] string - EOL character used. Defaults to \n.

table.load(data)

Set the input data to display. Must be an array of objects.

Kind: instance method of Table
Params

  • data Array.<object>

table.renderLines() ⇒ Array.<string>

Identical to .toString() with the exception that the result will be an array of lines, rather than a single, multi-line string.

Kind: instance method of Table

table.toString() ⇒ string

Returns the input data as a text table.

Kind: instance method of Table

Table~columnOption

Kind: inner typedef of Table
Properties

Name Type Description
name string column name, must match a property name in the input
[width] number A specific column width. Supply either this or a min and/or max width.
[minWidth] number column min width
[maxWidth] number column max width
[nowrap] boolean disable wrapping for this column
[break] boolean enable word-breaking for this columns
[padding] object padding options
[padding.left] string a string to pad the left of each cell (default: ' ')
[padding.right] string a string to pad the right of each cell (default: ' ')
[get] function A getter function to return the cell value, the function receives the existing cell value. Signature: function (cellValue) { // return the desired cell value }