1234567891011const WASM_NODE_MODULE_PATH =12 "node_modules/@subspace/reed-solomon-erasure.wasm/dist/reed_solomon_erasure_bg.wasm";1314type NodeFs = {15 readFileSync(path: string): Uint8Array;16};1718type NodePath = {19 resolve(...parts: string[]): string;20};2122async function importNodeModule<T>(name: string): Promise<T> {23 return import( (`node:${name}`)) as Promise<T>;24}2526export async function readNodeReedSolomonWasmBytes(): Promise<Uint8Array<ArrayBuffer>> {27 const [fs, path] = await Promise.all([28 importNodeModule<NodeFs>("fs"),29 importNodeModule<NodePath>("path"),30 ]);31 const fileBytes = fs.readFileSync(path.resolve(WASM_NODE_MODULE_PATH));32 const bytes: Uint8Array<ArrayBuffer> = new Uint8Array(fileBytes.byteLength);33 bytes.set(fileBytes);34 return bytes;35}