endojs / endo

Endo is a distributed secure JavaScript sandbox, based on SES
Apache License 2.0
761 stars 68 forks source link

docs(patterns): Comments for fixed-length heterogeneous collection patterns #2291

Closed kriskowal closed 1 month ago

kriskowal commented 1 month ago

Until we have a rigorous treatment on the usage of patterns, this adds a bandaid to the code itself so anyone looking for how to make a pattern for a struct-like CopyRecord, tuple-like CopyArray, or fixed-length heterogeneous CopyMap will find their way.

kriskowal commented 1 month ago

Looks good so far. Do this symmetrically for CopyArrays, Taggeds, CopyMaps, and passable primitives. I think that covers all the cases, but you should double check whether I forgot anything.

Rewrote all sections to speak in terms of the copy data that each pattern matches instead of using TypeScript. Covered CopyRecord, CopyArray, and CopyMaps. Tags aren’t heterogeneous collections. CopySet and CopyBag are collections but can’t be fixed-length and heterogeneous with types for corresponding keys or indexes, so they’re out.