decode intel HEX format, and encode data to intel HEX format.
Install
npm install @eightnineight/intelhex-codec
Usage
import{intelhexCodec}from"intelhex-codec";importfsfrom"fs/promises";letfile=awaitfs.open("./test.hex");letinputString=awaitfile.readFile();constblocks=intelhexCodec.decode.fromString(inputString);consthexString=intelhexCodec.encode.asString(blocks);awaitfs.writeFile("./output.hex",hexString);// Set the max number of data bytes in each record line to 10 bytes. (default 16 bytes)consthexString2=intelhexCodec.encode.asString(blocks,10);awaitfs.writeFile("./output2.hex",hexString2);
//Blocks format exampleconstblocks=[{// block 1address: address1,// block 1 data start addressdata: [...],// block 1 data},{// block 2address: address2,// block 2 data start addressdata: [...],// block 2 data},//...];