(reader: BinaryReader)
| 16 | * @returns Throws a WebAssemblyDecodeError if the magic number does not match the expected value. |
| 17 | */ |
| 18 | export function readMagic(reader: BinaryReader) { |
| 19 | const startOffset = reader.currentOffset; |
| 20 | const magic = reader.readBytes(4); |
| 21 | if (!arrayBuffersEqual(MAGIC, magic)) { |
| 22 | throw new WebAssemblyDecodeError( |
| 23 | 'Specified module is not a valid binary WebAssembly module', |
| 24 | startOffset |
| 25 | ); |
| 26 | } |
| 27 | } |
| 28 | |
| 29 | /** |
| 30 | * Reads and returns a 32-bit unsigned integer representing the version |
no test coverage detected