@metamask/snaps-sdk
Version:
A library containing the core functionality for building MetaMask Snaps
32 lines • 969 B
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.createSnapComponent = void 0;
/**
* Remove undefined props from an object.
*
* @param props - The object to remove undefined props from.
* @returns The object without undefined props.
*/
function removeUndefinedProps(props) {
return Object.fromEntries(Object.entries(props).filter(([, value]) => value !== undefined));
}
/**
* Create a Snap component from a type. This is a helper function that creates a
* Snap component function.
*
* @param type - The type of the component.
* @returns A function that creates a Snap element.
* @see SnapComponent
*/
function createSnapComponent(type) {
return (props) => {
const { key = null, ...rest } = props;
return {
type,
props: removeUndefinedProps(rest),
key,
};
};
}
exports.createSnapComponent = createSnapComponent;
//# sourceMappingURL=component.cjs.map