Options
All
  • Public
  • Public/Protected
  • All
Menu

Class TableHelper

A set of helper functions for manipulating and working with Tables

Hierarchy

  • TableHelper

Index

Methods

Static IndexTable

  • IndexTable(tbl: Table, column: string): object
  • Creates a dict keyed on unique values in a column of the root level rows with that value

    Parameters

    • tbl: Table

      The table to index on

    • column: string

      The column in tbl to index on. Note that it's values MUST be valid PropertyKeys!

    Returns object

    A dictionary of rows having the value 'key' at the given column

    • [index: string]: object
      • [column: string]: any

Static Join

  • Performs a join on the root-level rows of the given tables IMPORTANT! This does not support group rows, nor does it support outer joins.

    Parameters

    • LeftTable: Table

      The left table of the join

    • RightTable: Table

      The right table of the join

    • type: JoinType

      What type of join to perform. Valid options are Union, LeftOuter, and RightOuter

    • leftcol: string

      The column of the left table to join on

    • rightcol: string

      The column of the right table to join on

    Returns Table

    A new, joined table

Static Union

  • Performs a InnerJoin on the given Tables, with the optional ability to only allow same-column InnerJoins

    Parameters

    • LeftTable: Table

      The left table of the join

    • RightTable: Table

      The right table of the join

    • strict: boolean

      Whether to enforce both tables having the same column

    Returns Table

Static Private _depthFirstWalk

  • _depthFirstWalk(result: any[], obj: any, getChildren: function): void
  • Parameters

    • result: any[]
    • obj: any
    • getChildren: function
        • (obj: any): any[]
        • Parameters

          • obj: any

          Returns any[]

    Returns void

Static depthFirstWalk

  • depthFirstWalk(obj: any, getChildren: function): any[]
  • A helper function to perform a DFS on the obj and any children

    example

    let flatRows = TableHelper.depthFirstWalk(myTable.rows, (obj: Row) => row.children);

    Parameters

    • obj: any

      The object, or list of objects, to traverse

    • getChildren: function

      A lambda that will be called on every visted node. This must return a list of all it's children, or nothing/an empty array if the node is a leaf node

        • (obj: any): any[]
        • Parameters

          • obj: any

          Returns any[]

    Returns any[]

    The flattened list of nodes to walk

Static flattenTable

  • Returns a table where all grouped rows are flattened into root rows This is useful for interoperability with code that doesn't support grouping, but needs the contents of the grouped rows.

    Parameters

    • input: Table

      The table to convert

    Returns Table

    A copy of the table that has been flattened

Static fromMQLResultTable

  • Converts an {MqlResultTable} back into a Table

    Parameters

    • input: MqlResultTable

      The result table to convert

    • Default value parentTable: Table = new Table()

    Returns Table

    The converted table. Note that this is the same objectreference as parentTable

Static fromMatrixObject

  • fromMatrixObject(rows: any[][], columns: string[]): Table
  • Converts a matrix of values into a Table

    Parameters

    • rows: any[][]

      The matrix of values. Note that all rows must be the same length.

    • columns: string[]

      The column names to use when converting into a Table.

    Returns Table

    A new Table

Static fromObjectArray

  • fromObjectArray(input: any[], inferTypes?: boolean): Table
  • Converts an array of objects keyed on column names to a Table

    Parameters

    • input: any[]

      The array of objects to convert

    • Default value inferTypes: boolean = true

    Returns Table

    A new, flat Table

Static getRowPath

  • getRowPath(row: Row): string
  • Constructs the row path for this row by traversing parent rows, constructing a slash-separated string of rowNames

    Parameters

    • row: Row

      The row to find the path of

    Returns string

    Row path

Static toMQLResultTable

  • Convert a Table to a JSON format matching that of a ResultTable from MavenWebReflector. This is relevant for interoperability with MQL and MavenScape-style JSEPs. Flatten and calculate the special rowname/rowpath,rowdepth properties

    Parameters

    • input: Table

      The table to convert

    Returns MqlResultTable

Static toMatrixObject

  • toMatrixObject(table: Table): object
  • Converts a Table to a matrix object, wrapped in an object containing a list of column names for enhanced interoperability

    Parameters

    • table: Table

      The table to convert

    Returns object

Static toObjectArray

  • toObjectArray(table: Table): object[]
  • Converts a Table into an array of objects keyed on their columns Note that this only works on root rows! Grouped rows are dropped prior to conversion.

    Parameters

    • table: Table

      The flat table to convert

    Returns object[]

    An object array representing the table

Generated using TypeDoc