spiegel-keyman/common/tools/hextobin/filesystem.ts
Marc Durdin 36cd83f21b chore(common): cleanup and reorganize hextobin to remove fs dependency
fs dependency removed from the main hextobin function, only in the
filesystem.ts version. Also supports loading a segment of a hex file
for isolated tests.

Test-bot: skip
2026-03-12 16:26:08 +01:00

16 lines
501 B
TypeScript

/*
* Keyman is copyright (C) SIL Global. MIT License.
*
* hextobin filesystem interfaces
*/
import * as fs from 'node:fs';
import { hextobin, HexToBinOptions } from './main.js';
export function hextobinFromFile(inputFilename: string, outputFilename?: string, options?: HexToBinOptions): Uint8Array {
const result = hextobin(fs.readFileSync(inputFilename, 'utf-8'), options);
if(result && outputFilename) {
fs.writeFileSync(outputFilename, result);
}
return result;
}