mirror of
https://github.com/keymanapp/keyman.git
synced 2026-08-19 23:07:42 +00:00
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
16 lines
501 B
TypeScript
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;
|
|
}
|