UNPKG

396 BJavaScriptView Raw
1import { u8aEq } from '../u8a/eq.js';
2import { isU8a } from './u8a.js';
3const WASM_MAGIC = new Uint8Array([0, 97, 115, 109]); // \0asm
4/**
5 * @name isWasm
6 * @summary Tests if the input has a WASM header
7 * @description
8 * Checks to see if the input Uint8Array contains a valid WASM header
9 */
10export function isWasm(value) {
11 return isU8a(value) && u8aEq(value.subarray(0, 4), WASM_MAGIC);
12}