ixfx
    Preparing search index...

    Stores values in a table of rows (vertical) and columns (horizontal)

    Type Parameters

    • V
    Index

    Accessors

    Constructors

    Methods

    • Return a copy of table as nested array

      const t = new Table();
      // add stuff
      // ...
      const m = t.asArray();
      for (const row of m) {
      for (const colValue of row) {
      // iterate over all column values for this row
      }
      }

      Alternative: get value at row Y and column X

      const value = m[y][x];
      

      Returns (undefined | V)[][]

    • Gets the value at a specified row and column. Throws an error if coordinates are out of range or missing.

      Parameters

      • row: string | number

        Row index or label

      • column: string | number

        Column index or label

      Returns TableValue<V>

    • Gets the label for a given column index, returning undefined if not found.

      Case-sensitive

      Parameters

      • label: string

        Label to seek

      Returns undefined | number

      Index of column, or undefined if not found

    • Gets the label for a given row index, returning undefined if not found.

      Case-sensitive

      Parameters

      • label: string

        Label to seek

      Returns undefined | number

      Index of row, or undefined if not found

    • Gets a row along with labels, as an array

      Parameters

      • rowIndex: number

      Returns undefined | [label: string, value: V][]

    • Return a row of objects. Keys use the column labels.

      const row = table.getRowWithLabelsObject(10);
      // eg:
      // [{ colour: red, size: 10}, { colour: blue, size: 20 }]

      Parameters

      • rowIndex: number

      Returns undefined | object

    • Assign label to a specific column First column has an index of 0

      Parameters

      • columnIndex: number
      • label: string

      Returns void

    • Assign label to a specific row First row has an index of 0

      Parameters

      • rowIndex: number
      • label: string

      Returns void

    • Gets a copy of values at given row, specified by index or label

      Parameters

      • row: string | number

      Returns undefined | readonly (undefined | V)[]

      Returns row or throws an error if label or index not found

    • Iterates over each row, including the labels if available

      Returns Generator<undefined | [label: string, value: V][], void, unknown>

      rowsWithLabelsObject to get rows in object format

    • Set the value of row,columm. Row is created if it doesn't exist, with the other column values being undefined

      Parameters

      • row: string | number

        Index or label

      • column: string | number

        Column

      • value: undefined | V

        Value to set at row,column

      Returns void

    • Set all the columns of a row to a specified value.

      By default, sets the number of columns corresponding to the table's maximum column length. To set an arbitrary length of the row, use length

      Parameters

      • row: string | number

        Index or label of row

      • value: undefined | V

        Value to set

      • Optionallength: number

        How wide the row is. If unset, uses the current maximum width of rows.

      Returns TableRow<V>

    Properties

    colLabels: string[] = []
    columnMaxLength: number = 0

    Keep track of widest row

    rowLabels: string[] = []
    rows: TableRow<V>[] = []