@metamask/snaps-sdk
Version:
A library containing the core functionality for building MetaMask Snaps
29 lines • 1.13 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.assertIsComponent = exports.isComponent = void 0;
const superstruct_1 = require("@metamask/superstruct");
const utils_1 = require("@metamask/utils");
const components_1 = require("./components/index.cjs");
/**
* 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.
*/
function isComponent(value) {
return (0, superstruct_1.is)(value, components_1.ComponentStruct);
}
exports.isComponent = isComponent;
/**
* 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}.
*/
function assertIsComponent(value) {
(0, utils_1.assertStruct)(value, components_1.ComponentStruct, 'Invalid component');
}
exports.assertIsComponent = assertIsComponent;
//# sourceMappingURL=component.cjs.map