UNPKG

@metamask/ocap-kernel

Version:
17 lines 579 B
import { passStyleOf } from "@endo/pass-style"; import { kunser, krefOf } from "../../services/kernel-marshal.mjs"; /** * Obtain the KRef from a simple value represented as a CapData object. * * @param data - The data object to be examined. * @returns the single KRef that is `data`, or null if it isn't one. */ export function extractSingleRef(data) { const value = kunser(data); const style = passStyleOf(value); if (style === 'remotable' || style === 'promise') { return krefOf(value); } return null; } //# sourceMappingURL=extract-ref.mjs.map