@metamask/snaps-sdk
Version:
A library containing the core functionality for building MetaMask Snaps
24 lines • 858 B
JavaScript
import { is } from "@metamask/superstruct";
import { assertStruct } from "@metamask/utils";
import { ComponentStruct } from "./components/index.mjs";
/**
* Check if the given value is a {@link Component}. This performs recursive
* validation of the component's children (if any).
*
* @param value - The value to check.
* @returns `true` if the value is a {@link Component}, `false` otherwise.
*/
export function isComponent(value) {
return is(value, ComponentStruct);
}
/**
* Assert that the given value is a {@link Component}. This performs recursive
* validation of the component's children (if any).
*
* @param value - The value to check.
* @throws If the value is not a {@link Component}.
*/
export function assertIsComponent(value) {
assertStruct(value, ComponentStruct, 'Invalid component');
}
//# sourceMappingURL=component.mjs.map