import { readFile, writeFile } from "node:fs/promises"; const controlPath = new URL("./control.armnn", import.meta.url); const triggerPath = new URL("./trigger.armnn", import.meta.url); const bytes = await readFile(controlPath); const discriminatorOffset = 763; if (bytes.length !== 908 || bytes[discriminatorOffset] !== 0x09) { throw new Error( `unexpected control fixture at offset ${discriminatorOffset}: ` + `length=${bytes.length}, byte=0x${bytes[discriminatorOffset]?.toString(16)}`, ); } bytes[discriminatorOffset] = 0x7b; await writeFile(triggerPath, bytes); console.log( `wrote ${bytes.length} bytes; AnyLayer.layer_type byte ` + `at offset ${discriminatorOffset} changed from 0x09 to 0x7b`, );