withRefsInContext(ctx: Context): Context
Ensures that a context has the necessary reference storage initialized.
This function checks if the given context already has reference storage and initializes it if not. It's typically called before encoding/decoding operations that use references.
Example 1
Example 1
import { assertEquals } from "@std/assert"; import { withRefsInContext } from "./ref.ts"; import { createContext } from "../core.ts"; // Create a basic context const ctx = createContext("encode"); // Initialize it with reference support const ctxWithRefs = withRefsInContext(ctx); // Verify the context now has reference storage assertEquals(ctxWithRefs === ctx, true);