feat(marshal): new methods {to,from}CapData
MODIFY
packages/marshal/src/marshal.js
packages/marshal/src/marshal.js
@@ -73,7 +73,7 @@ export const makeMarshal = (
/**
* @type {ToCapData<Slot>}
*/
- const serialize = root => {
+ const toCapData = root => {
const slots = [];
// maps val (promise or remotable) to index of slots[]
const slotMap = new Map();
@@ -342,7 +342,7 @@ export const makeMarshal = (
/**
* @type {FromCapData<Slot>}
*/
- const unserialize = data => {
+ const fromCapData = data => {
const { body, slots } = data;
typeof body === 'string' ||
Fail`unserialize() given non-capdata (.body is ${body}, not string)`;
@@ -367,7 +367,13 @@ export const makeMarshal = (
};
return harden({
- serialize,
- unserialize,
+ toCapData,
+ fromCapData,
+
+ // for backwards compatibility
+ /** @deprecated use toCapData */
+ serialize: toCapData,
+ /** @deprecated use fromCapData */
+ unserialize: fromCapData,
});
};

MODIFY
packages/marshal/src/types.js
packages/marshal/src/types.js
@@ -99,8 +99,10 @@ export {};
/**
* @template Slot
* @typedef {Object} Marshal
- * @property {ToCapData<Slot>} serialize
- * @property {FromCapData<Slot>} unserialize
+ * @property {ToCapData<Slot>} serialize use toCapData
+ * @property {FromCapData<Slot>} unserialize use fromCapData
+ * @property {ToCapData<Slot>} toCapData
+ * @property {FromCapData<Slot>} fromCapData
*/
/**

feat(marshal): new methods {to,from}CapData