import { type WhenDone } from "https://deno.land/x/cav@0.0.21/mod.ts";
A Serializer's deserialize()
function receives the raw serialized JSON
value as its first argument and this registration function as the second.
Functions registered with whenDone will be run last-in-first-out (stack
order) when the raw JSON has been processed into the final object instance.
WhenDone functions are needed whenever the serialized data is more complex
than simple JSON values, for example when referential equality needs to be
maintained or when the serialize function returns anything that needs to be
re-serialized by some other serializer. Referenced objects may not be fully
initialized when the registered function is called, but its instance will be
instantiated so that references can be fixed.
Credit goes to json-dry for the whenDone concept.