mirror of
https://github.com/asadbek064/hyparquet.git
synced 2025-12-06 06:51:54 +00:00
24 lines
484 B
JavaScript
24 lines
484 B
JavaScript
import fs from 'fs'
|
|
|
|
/**
|
|
* Read file and parse as JSON
|
|
*
|
|
* @param {string} filePath
|
|
* @returns {any}
|
|
*/
|
|
export function fileToJson(filePath) {
|
|
const buffer = fs.readFileSync(filePath)
|
|
return JSON.parse(buffer.toString())
|
|
}
|
|
|
|
/**
|
|
* Make a DataReader from bytes
|
|
*
|
|
* @import {DataReader} from '../src/types.d.ts'
|
|
* @param {number[]} bytes
|
|
* @returns {DataReader}
|
|
*/
|
|
export function reader(bytes) {
|
|
return { view: new DataView(new Uint8Array(bytes).buffer), offset: 0 }
|
|
}
|