hyparquet/test/helpers.js

23 lines
462 B
JavaScript
Raw Normal View History

2024-01-20 20:17:11 +00:00
import fs from 'fs'
2024-02-13 18:52:29 +00:00
/**
* Read .parquet file into JSON
*
* @param {string} filePath
* @returns {any}
*/
export function fileToJson(filePath) {
const buffer = fs.readFileSync(filePath)
return JSON.parse(buffer.toString())
}
2024-05-28 20:59:06 +00:00
/**
* Make a DataReader from bytes
*
* @param {number[]} bytes
* @returns {import('../src/types.js').DataReader}
*/
export function reader(bytes) {
return { view: new DataView(new Uint8Array(bytes).buffer), offset: 0 }
}