voici.js
    Preparing search index...

    Class Table<TRow, TDColumns>

    Represent a dataset in tabular form. The columns are infered from the dataset's first item.

    Type Parameters

    • TRow extends Row

      Type of a dataset row.

    • TDColumns extends object = never

      Type of the dynamic columns.

    Index

    Constructors

    Accessors

    • get config(): Required<
          Partial<
              {
                  align: "LEFT"
                  | "CENTER"
                  | "RIGHT";
                  bgColorColumns: string[];
                  body: Partial<
                      {
                          accumulation: Partial<
                              {
                                  bgColor: string;
                                  columns: Partial<Accumulation<TRow, TDColumns>>;
                                  separator: string;
                              },
                          >;
                          bgColor: string;
                          fillEmpty: Partial<FillEmptyOption<DatasetRow<TRow, TDColumns>>>;
                          filterRow: (row: DatasetRow<TRow, TDColumns>, index: number) => boolean;
                          highlightCell: Partial<
                              {
                                  bold: boolean;
                                  func: (
                                      content: unknown,
                                      row: number,
                                      col: InferAttributes<TRow, TDColumns>,
                                  ) => boolean;
                                  italic: boolean;
                                  textColor: string;
                                  underline: boolean;
                              },
                          >;
                          highlightRow: Partial<
                              {
                                  bgColor: string;
                                  func: (row: DatasetRow<TRow, TDColumns>, index: number) => boolean;
                              },
                          >;
                          peek: number
                          | [number, number];
                          precision: number;
                          striped: boolean;
                          subset: [number?, number?];
                          textColor: string;
                      },
                  >;
                  border: Partial<
                      {
                          color: string;
                          groupSize: number;
                          horizontal: string;
                          vertical: string;
                      },
                  >;
                  header: Partial<
                      {
                          bgColor: string;
                          bold: boolean;
                          displayNames: Partial<
                              { [key in InferRowAttributesOrigin<TRow>]: string },
                          >;
                          dynamic: DynamicColumn<TRow, TDColumns>;
                          exclude: InferRowAttributes<TRow>[];
                          include: InferRowAttributes<TRow>[];
                          italic: boolean;
                          lowercase: boolean;
                          maxWidth: number | "auto";
                          order: InferAttributesOrigin<TRow, TDColumns>[];
                          origin: boolean;
                          separator: string;
                          textColor: string;
                          underline: boolean;
                          uppercase: boolean;
                          upperfirst: boolean;
                          visible: boolean;
                          width: number | "auto" | "stretch";
                      },
                  >;
                  padding: Partial<{ char: string; size: number }>;
                  sort: Sort<InferAttributesOrigin<TRow, TDColumns>>;
              },
          >,
      >

      Returns Required<
          Partial<
              {
                  align: "LEFT"
                  | "CENTER"
                  | "RIGHT";
                  bgColorColumns: string[];
                  body: Partial<
                      {
                          accumulation: Partial<
                              {
                                  bgColor: string;
                                  columns: Partial<Accumulation<TRow, TDColumns>>;
                                  separator: string;
                              },
                          >;
                          bgColor: string;
                          fillEmpty: Partial<FillEmptyOption<DatasetRow<TRow, TDColumns>>>;
                          filterRow: (row: DatasetRow<TRow, TDColumns>, index: number) => boolean;
                          highlightCell: Partial<
                              {
                                  bold: boolean;
                                  func: (
                                      content: unknown,
                                      row: number,
                                      col: InferAttributes<TRow, TDColumns>,
                                  ) => boolean;
                                  italic: boolean;
                                  textColor: string;
                                  underline: boolean;
                              },
                          >;
                          highlightRow: Partial<
                              {
                                  bgColor: string;
                                  func: (row: DatasetRow<TRow, TDColumns>, index: number) => boolean;
                              },
                          >;
                          peek: number
                          | [number, number];
                          precision: number;
                          striped: boolean;
                          subset: [number?, number?];
                          textColor: string;
                      },
                  >;
                  border: Partial<
                      {
                          color: string;
                          groupSize: number;
                          horizontal: string;
                          vertical: string;
                      },
                  >;
                  header: Partial<
                      {
                          bgColor: string;
                          bold: boolean;
                          displayNames: Partial<
                              { [key in InferRowAttributesOrigin<TRow>]: string },
                          >;
                          dynamic: DynamicColumn<TRow, TDColumns>;
                          exclude: InferRowAttributes<TRow>[];
                          include: InferRowAttributes<TRow>[];
                          italic: boolean;
                          lowercase: boolean;
                          maxWidth: number | "auto";
                          order: InferAttributesOrigin<TRow, TDColumns>[];
                          origin: boolean;
                          separator: string;
                          textColor: string;
                          underline: boolean;
                          uppercase: boolean;
                          upperfirst: boolean;
                          visible: boolean;
                          width: number | "auto" | "stretch";
                      },
                  >;
                  padding: Partial<{ char: string; size: number }>;
                  sort: Sort<InferAttributesOrigin<TRow, TDColumns>>;
              },
          >,
      >

    • get shape(): [rows: number, columns: number]

      Returns [rows: number, columns: number]

    Methods

    • Exports the plain table to the given file (without advanced style).

      Parameters

      • filepath: string

        the filepath

      • mode: OpenMode = 'w'

        the file's open mode

      Returns void

    • Gets the value of the given cell in the dataset.

      Parameters

      • row: number

        the cell's row

      • col: InferDatasetRowAttributesOrigin<TRow, TDColumns>

        the cell's col

      Returns AccumulationRow<TRow, TDColumns>[InferDatasetRowAttributesOrigin<
          TRow,
          TDColumns,
      >]

      the cell's value

    • Prints the table to the console.

      Parameters

      • clear: boolean = false

        clear the console before printing

      Returns void

    • Prints the plain (unstyled) table to the console.

      Returns void

    • Gets the table as plain string without any advanced styling. Can be used for example to write the table to a file or to paste it anywhere as text.

      Returns string

      the plain table string

    • Gets the table as string. Can be used to print the table on the console.

      Returns string

      the table string