Revert onComplete type signature change from #25

The type change caused a lot of downstream type errors.
If you pass rowFormat: 'object' then it will return Record<string, any>[]
instead of any[][]. This means the types are not aligned with behavior.
Will figure out how to fix it later, for now don't want break downstream projects.
This commit is contained in:
Kenny Daniel 2024-08-14 21:51:33 -07:00
parent da9fbc68b8
commit b1c8a1dd8b
No known key found for this signature in database
GPG Key ID: 90AB653A8CAD7E45
3 changed files with 4 additions and 4 deletions

@ -112,7 +112,7 @@ async function render(asyncBuffer, metadata, name) {
compressors,
file: asyncBuffer,
rowEnd: 1000,
onComplete(/** @type {any[][] | Record<string, any>[]} */ data) {
onComplete(/** @type {any[][]} */ data) {
const ms = performance.now() - startTime
console.log(`parsed ${name} in ${ms.toFixed(0)} ms`)
content.appendChild(renderTable(header, data))

2
src/hyparquet.d.ts vendored

@ -116,7 +116,7 @@ export interface ParquetReadOptions {
rowStart?: number // inclusive
rowEnd?: number // exclusive
onChunk?: (chunk: ColumnData) => void // called when a column chunk is parsed. chunks may be outside the requested range.
onComplete?: (rows: any[][] | Record<string, any>[]) => void // called when all requested rows and columns are parsed
onComplete?: (rows: any[][]) => void // called when all requested rows and columns are parsed
compressors?: Compressors // custom decompressors
utf8?: boolean // decode byte arrays as utf8 strings (default true)
}

@ -27,7 +27,7 @@ import { concat } from './utils.js'
* @param {number} [options.rowStart] first requested row index (inclusive)
* @param {number} [options.rowEnd] last requested row index (exclusive)
* @param {(chunk: ColumnData) => void} [options.onChunk] called when a column chunk is parsed. chunks may include row data outside the requested range.
* @param {(rows: any[][] | Record<string, any>[]) => void} [options.onComplete] called when all requested rows and columns are parsed
* @param {(rows: any[][]) => void} [options.onComplete] called when all requested rows and columns are parsed
* @param {Compressors} [options.compressors] custom decompressors
* @returns {Promise<void>} resolves when all requested rows and columns are parsed
*/
@ -76,7 +76,7 @@ export async function parquetRead(options) {
* @param {string[]} [options.columns] columns to read, all columns if undefined
* @param {string} [options.rowFormat] format of each row passed to the onComplete function
* @param {(chunk: ColumnData) => void} [options.onChunk] called when a column chunk is parsed. chunks may include row data outside the requested range.
* @param {(rows: any[][] | Record<string, any>[]) => void} [options.onComplete] called when all requested rows and columns are parsed
* @param {(rows: any[][]) => void} [options.onComplete] called when all requested rows and columns are parsed
* @param {Compressors} [options.compressors]
* @param {RowGroup} rowGroup row group to read
* @param {number} groupStart row index of the first row in the group