Skip to content

Commit

Permalink
fix(marshal): Add a smaller and more efficient passable encoding (merge
Browse files Browse the repository at this point in the history
  • Loading branch information
gibson042 authored Feb 5, 2024
2 parents 96e777c + 70bcca3 commit f721c3a
Show file tree
Hide file tree
Showing 4 changed files with 687 additions and 91 deletions.
19 changes: 19 additions & 0 deletions packages/marshal/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,25 @@ console.log(o1 === o2);
// false
```

Additionally, this module exports a `makePassableKit` function for encoding into
and decoding from a directly-serialized format in which string comparison
corresponds with arbitrary value comparison (cf.
[Patterns: Rank order and key order](https://github.com/endojs/endo/blob/master/packages/patterns/README.md#rank-order-and-key-order).
Rather than accepting `convertValToSlot` and `convertSlotToVal` functions and
keeping a "slots" side table, `makePassableKit` expects
{encode,decode}{Remotable,Promise,Error} functions that directly convert between
instances of the respective pass styles and properly-formatted encodings
(in which Remotable encodings start with "r", Promise encodings start with "?",
Error encodings start with "!", and all other details are left to the provided
functions).
`makePassableKit` supports two variations of this format: "legacyOrdered" and
"compactOrdered". The former is the default for historical reasons (see
https://github.com/endojs/endo/pull/1594 for background) but the latter is
preferred for its better handling of deep structure. The ordering guarantees are
upheld within each format variation, but not across them (i.e., it is not
correct to treat a string comparison of legacyOrdered vs. compactOrdered as a
corresponding value comparison).

## Frozen Objects Only

The entire object graph must be "hardened" (recursively frozen), such as done
Expand Down
1 change: 1 addition & 0 deletions packages/marshal/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ export { stringify, parse } from './src/marshal-stringify.js';
export { decodeToJustin } from './src/marshal-justin.js';

export {
makePassableKit,
makeEncodePassable,
makeDecodePassable,
isEncodedRemotable,
Expand Down
Loading

0 comments on commit f721c3a

Please sign in to comment.