UNPKG

595 BJavaScriptView Raw
1"use strict";
2Object.defineProperty(exports, "__esModule", { value: true });
3exports.isRiscV = void 0;
4const eq_js_1 = require("../u8a/eq.js");
5const u8a_js_1 = require("./u8a.js");
6const ELF_MAGIC = new Uint8Array([0x7f, 0x45, 0x4c, 0x46]); // ELF magic bytes: 0x7f, 'E', 'L', 'F'
7/**
8 * @name isRiscV
9 * @summary Tests if the input has a RISC-V header
10 * @description
11 * Checks to see if the input Uint8Array contains a valid RISC-V header
12 */
13function isRiscV(bytes) {
14 return (0, u8a_js_1.isU8a)(bytes) && (0, eq_js_1.u8aEq)(bytes.subarray(0, 4), ELF_MAGIC);
15}
16exports.isRiscV = isRiscV;