@metamask/ocap-kernel
Version:
OCap kernel core components
1 lines • 1.23 kB
Source Map (JSON)
{"version":3,"file":"extract-ref.cjs","sourceRoot":"","sources":["../../../src/store/utils/extract-ref.ts"],"names":[],"mappings":";;AAaA,4CAOC;AAnBD,iDAA+C;AAE/C,yEAAkE;AAIlE;;;;;GAKG;AACH,SAAgB,gBAAgB,CAAC,IAAmB;IAClD,MAAM,KAAK,GAAG,IAAA,0BAAM,EAAC,IAAI,CAAc,CAAC;IACxC,MAAM,KAAK,GAAW,IAAA,wBAAW,EAAC,KAAK,CAAC,CAAC;IACzC,IAAI,KAAK,KAAK,WAAW,IAAI,KAAK,KAAK,SAAS,EAAE,CAAC;QACjD,OAAO,IAAA,0BAAM,EAAC,KAAK,CAAC,CAAC;IACvB,CAAC;IACD,OAAO,IAAI,CAAC;AACd,CAAC","sourcesContent":["import type { CapData } from '@endo/marshal';\nimport { passStyleOf } from '@endo/pass-style';\n\nimport { kunser, krefOf } from '../../services/kernel-marshal.ts';\nimport type { SlotValue } from '../../services/kernel-marshal.ts';\nimport type { KRef } from '../../types.ts';\n\n/**\n * Obtain the KRef from a simple value represented as a CapData object.\n *\n * @param data - The data object to be examined.\n * @returns the single KRef that is `data`, or null if it isn't one.\n */\nexport function extractSingleRef(data: CapData<KRef>): KRef | null {\n const value = kunser(data) as SlotValue;\n const style: string = passStyleOf(value);\n if (style === 'remotable' || style === 'promise') {\n return krefOf(value);\n }\n return null;\n}\n"]}