Options
All
  • Public
  • Public/Protected
  • All
Menu

Class Tablur

Hierarchy

  • Tablur

Index

Constructors

constructor

Properties

Private _footer

_footer: Tablur

Private _header

_header: Tablur

Private _indexed

_indexed: ITablurMap<number>

Private _rows

_rows: ITablurColumnInternal[][] = []

options

Accessors

size

  • get size(): object
  • Gets the size of the terminal columns and rows.

    Returns object

    • columns: number
    • rows: number

Methods

break

  • break(): this
  • Creates an empty break in the table.

    example

    .break();

    Returns this

Private buildRow

Private calculateOffset

  • calculateOffset(columns: number, padding: number, border: boolean): number
  • Parameters

    • columns: number
    • padding: number
    • border: boolean

    Returns number

clear

  • clear(): this

colorize

  • colorize(str: string, styles?: TablurColor | IAnsiStyles | IAnsiStyles[]): string
  • Parameters

    • str: string

      a string to be colorized.

    • Optional styles: TablurColor | IAnsiStyles | IAnsiStyles[]

    Returns string

Private columnCounts

configure

  • Configures rows for output adjusting and normalizing cells.

    example

    .configure({ // optional parent config });

    Parameters

    • Optional config: ITablurConfig

      optional parent configuration to override with.

    Returns ITablurConfig

Protected fillArray

  • fillArray(count: number, val?: any): any[]
  • Parameters

    • count: number
    • Default value val: any = ""

    Returns any[]

Protected findIndices

  • findIndices(str: string, char: string): any[]
  • Parameters

    • str: string
    • char: string

    Returns any[]

footer

  • Add footer row with alignment.

    example

    .footer('copyright 2018', TablerAlign.center);

    Parameters

    • text: string

      footer column text.

    • Optional align: TablurAlign

      column alignment.

    Returns Tablur

  • Add footer row with options.

    example

    .footer({ text: 'copyright 2018' }, { option overrides });

    Parameters

    • col: string | ITablurColumn

      footer column title or configuration object.

    • Optional options: ITablurOptionsBase

      options used to override inherited defaults.

    Returns Tablur

  • Add footer row with options.

    example

    .footer('Column 1', 'Column 2'..., { option overrides });

    Parameters

    • col1: string | ITablurColumn

      footer column title or configuration object.

    • col2: string | ITablurColumn

      footer column title or configuration object.

    • Optional options: ITablurOptionsBase

      options used to override inherited defaults.

    Returns Tablur

  • Add footer row with options.

    example

    .footer('Column 1', 'Column 2'..., { option overrides });

    Parameters

    • col1: string | ITablurColumn

      footer column title or configuration object.

    • col2: string | ITablurColumn

      footer column title or configuration object.

    • col3: string | ITablurColumn

      footer column title or configuration object.

    • Optional options: ITablurOptionsBase

      options used to override inherited defaults.

    Returns Tablur

  • Add footer row with options.

    example

    .footer('Column 1', 'Column 2'..., { option overrides });

    Parameters

    • col1: string | ITablurColumn

      footer column title or configuration object.

    • col2: string | ITablurColumn

      footer column title or configuration object.

    • col3: string | ITablurColumn

      footer column title or configuration object.

    • col4: string | ITablurColumn

      footer column title or configuration object.

    • Optional options: ITablurOptionsBase

      options used to override inherited defaults.

    Returns Tablur

  • Add footer row with options.

    example

    .footer('Column 1', 'Column 2'..., { option overrides });

    Parameters

    • col1: string | ITablurColumn

      footer column title or configuration object.

    • col2: string | ITablurColumn

      footer column title or configuration object.

    • col3: string | ITablurColumn

      footer column title or configuration object.

    • col4: string | ITablurColumn

      footer column title or configuration object.

    • col5: string | ITablurColumn

      footer column title or configuration object.

    • Optional options: ITablurOptionsBase

      options used to override inherited defaults.

    Returns Tablur

  • Add footer row with options.

    example

    .footer('Column 1', 'Column 2'..., { option overrides });

    Parameters

    • col1: string | ITablurColumn

      footer column title or configuration object.

    • col2: string | ITablurColumn

      footer column title or configuration object.

    • col3: string | ITablurColumn

      footer column title or configuration object.

    • col4: string | ITablurColumn

      footer column title or configuration object.

    • col5: string | ITablurColumn

      footer column title or configuration object.

    • col6: string | ITablurColumn

      footer column title or configuration object.

    • Optional options: ITablurOptionsBase

      options used to override inherited defaults.

    Returns Tablur

  • Add footer using columns.

    Parameters

    Returns Tablur

header

  • Add header row with alignment.

    example

    .header('My Header', TablerAlign.center);

    Parameters

    • text: string

      header column text.

    • Optional align: TablurAlign

      column alignment.

    Returns Tablur

  • Add footer row with options.

    example

    .footer({ text: 'copyright 2018' }, { option overrides });

    Parameters

    • col: string | ITablurColumn

      footer column title or configuration object.

    • Optional options: ITablurOptionsBase

      options used to override inherited defaults.

    Returns Tablur

  • Add footer row with options.

    example

    .footer('Column 1', 'Column 2'..., { option overrides });

    Parameters

    • col1: string | ITablurColumn

      footer column title or configuration object.

    • col2: string | ITablurColumn

      footer column title or configuration object.

    • Optional options: ITablurOptionsBase

      options used to override inherited defaults.

    Returns Tablur

  • Add footer row with options.

    example

    .footer('Column 1', 'Column 2'..., { option overrides });

    Parameters

    • col1: string | ITablurColumn

      footer column title or configuration object.

    • col2: string | ITablurColumn

      footer column title or configuration object.

    • col3: string | ITablurColumn

      footer column title or configuration object.

    • Optional options: ITablurOptionsBase

      options used to override inherited defaults.

    Returns Tablur

  • Add footer row with options.

    example

    .footer('Column 1', 'Column 2'..., { option overrides });

    Parameters

    • col1: string | ITablurColumn

      footer column title or configuration object.

    • col2: string | ITablurColumn

      footer column title or configuration object.

    • col3: string | ITablurColumn

      footer column title or configuration object.

    • col4: string | ITablurColumn

      footer column title or configuration object.

    • Optional options: ITablurOptionsBase

      options used to override inherited defaults.

    Returns Tablur

  • Add footer row with options.

    example

    .footer('Column 1', 'Column 2'..., { option overrides });

    Parameters

    • col1: string | ITablurColumn

      footer column title or configuration object.

    • col2: string | ITablurColumn

      footer column title or configuration object.

    • col3: string | ITablurColumn

      footer column title or configuration object.

    • col4: string | ITablurColumn

      footer column title or configuration object.

    • col5: string | ITablurColumn

      footer column title or configuration object.

    • Optional options: ITablurOptionsBase

      options used to override inherited defaults.

    Returns Tablur

  • Add footer row with options.

    example

    .footer('Column 1', 'Column 2'..., { option overrides });

    Parameters

    • col1: string | ITablurColumn

      footer column title or configuration object.

    • col2: string | ITablurColumn

      footer column title or configuration object.

    • col3: string | ITablurColumn

      footer column title or configuration object.

    • col4: string | ITablurColumn

      footer column title or configuration object.

    • col5: string | ITablurColumn

      footer column title or configuration object.

    • col6: string | ITablurColumn

      footer column title or configuration object.

    • Optional options: ITablurOptionsBase

      options used to override inherited defaults.

    Returns Tablur

  • Add header using columns.

    Parameters

    Returns Tablur

Protected horizontalFill

  • horizontalFill(width: number, char: string, endcap?: string, offset?: number): string
  • Parameters

    • width: number
    • char: string
    • Optional endcap: string
    • Default value offset: number = 0

    Returns string

Private init

  • init(): void

Protected isBaseOptions

  • isBaseOptions(obj: any): number | false
  • Parameters

    • obj: any

    Returns number | false

Protected layoutWidth

  • layoutWidth(width?: number): number
  • Parameters

    • Optional width: number

    Returns number

Protected pad

  • pad(str: string, width: number, align?: TablurAlign): string
  • Parameters

    • str: string
    • width: number
    • Default value align: TablurAlign = TablurAlign.left

    Returns string

render

  • Render the rows into array of strings.

    example

    .render({ // optional parent config });

    Parameters

    • Optional pconfig: ITablurConfig

      the parent's parsed column metadata.

    Returns string[]

Private renderColumnsAdjust

Private renderFooter

Private renderHeader

reset

row

  • Adds a new row to the instance.

    example

    .row('column 1', { text: 'column 2' });

    Parameters

    • Rest ...cols: (string | ITablurColumn)[]

      the columns of the row to be added.

    Returns this

rows

  • Adds multiple rows containing table columns.

    example

    .rows([ ['row1-col1], [{ text: 'row2-col1 }] ]);

    Parameters

    • rows: (string | ITablurColumn)[][]

      the rows of table columns to add.

    Returns this

section

  • Adds a row as a section header.

    example

    .section({ text: 'Section:' , align: TablerAlign.center });

    Parameters

    Returns Tablur

  • Adds a row as a section header.

    example

    .section('Section:', TablerAlign.left);

    Parameters

    • name: string

      the name or title of the section.

    • Optional align: TablurAlign

      the alignment for the section title.

    Returns Tablur

Protected sum

  • sum(nums: number[]): number
  • Parameters

    • nums: number[]

    Returns number

Protected toArray

  • toArray(val: any, def?: any[]): any[]
  • Parameters

    • val: any
    • Default value def: any[] = []

    Returns any[]

Protected toColumn

Protected toPercentage

  • toPercentage(num: number, of?: number, places?: number): number
  • Parameters

    • num: number
    • Default value of: number = 100
    • Optional places: number

    Returns number

toString

  • toString(): string

Protected truncate

  • truncate(str: string, len: number): string
  • Parameters

    • str: string
    • len: number

    Returns string

Protected wrap

  • wrap(width: number, fill: number, border?: TablurBorder, indices?: number[]): object
  • Wrap creates border wrap and builds fill rows for padding.

    example

    .wrap(75, 3, TablerBorder.round, [0, 12, 40]);

    Parameters

    • width: number

      the width of the element to border wrap.

    • fill: number

      the fill count for padding.

    • Optional border: TablurBorder

      the border to use.

    • Optional indices: number[]

      indices to match bordering for fill rows.

    Returns object

    • bottom: string
    • fill: any
    • top: string

write

  • write(wrap?: string | WritableStream, stream?: WritableStream): void
  • Writes table to output stream with optional wrapping. By default tables are wrapped with empty lines. Set to null to disable.

    example

    .write();

    example

    .write(process.stderr);

    example

    .write('-------------------------------');

    Parameters

    • Default value wrap: string | WritableStream = " "

      when true wrap with char repeated on top and bottom.

    • Default value stream: WritableStream = process.stdout

      optional NodeJS.Writeable stream to output to.

    Returns void

Generated using TypeDoc