/** * Copyright (c) 2017 mol* contributors, licensed under MIT, See LICENSE file for more info. * * @author David Sehnal */ import { Column } from './column.js'; /** A collection of columns */ type Table = { readonly _rowCount: number; readonly _columns: ReadonlyArray; readonly _schema: Schema; } & Table.Columns; /** An immutable table */ declare namespace Table { type Schema = { [field: string]: Column.Schema; }; type Columns = { [C in keyof S]: Column; }; type Row = { [C in keyof S]: S[C]['T']; }; type Arrays = { [C in keyof S]: ArrayLike; }; type PartialColumns = { [C in keyof S]?: Column; }; type PartialTable = { readonly _rowCount: number; readonly _columns: ReadonlyArray; } & PartialColumns; function is(t: any): t is Table; function pickColumns(schema: S, table: PartialTable, guard?: Partial>): Table; function ofColumns = Table>(schema: S, columns: Columns): R; function ofPartialColumns = Table>(schema: S, partialColumns: PartialColumns, rowCount: number): R; function ofUndefinedColumns = Table>(schema: S, rowCount: number): R; function ofRows = Table>(schema: S, rows: ArrayLike>>): R; function ofArrays = Table>(schema: S, arrays: Partial>): R; function view(table: Table, schema: R, view: ArrayLike): Table; function pick(table: Table, schema: R, test: (i: number) => boolean): Table; function window(table: Table, schema: R, start: number, end: number): Table; function concat(tables: Table[], schema: R): Table; function columnToArray(table: Table, name: keyof S, array?: Column.ArrayCtor): void; /** Sort and return a new table */ function sort(table: T, cmp: (i: number, j: number) => number): any; function areEqual>(a: T, b: T): boolean; /** Allocate a new object with the given row values. */ function getRow(table: Table, index: number): Row; /** Pick the first row for which `test` evaluates to true */ function pickRow(table: Table, test: (i: number) => boolean): Row | undefined; function getRows(table: Table): Row[]; function toArrays(table: Table): { [k in keyof S]: ArrayLike; }; function formatToString(table: Table): string; } export { Table };