UNPKG

495 BJavaScriptView Raw
1// Copyright 2017-2022 @polkadot/util authors & contributors
2// SPDX-License-Identifier: Apache-2.0
3import { u8aEq } from "../u8a/eq.js";
4import { isU8a } from "./u8a.js";
5const WASM_MAGIC = new Uint8Array([0, 97, 115, 109]); // \0asm
6
7/**
8 * @name isWasm
9 * @summary Tests if the input has a WASM header
10 * @description
11 * Checks to see if the input Uint8Array contains a valid WASM header
12 */
13
14export function isWasm(value) {
15 return isU8a(value) && u8aEq(value.subarray(0, 4), WASM_MAGIC);
16}
\No newline at end of file