import * as cav from "https://deno.land/x/cav@0.0.14/browser.ts";
Functions
Constructs a new Client tied to a given base URL. The provided set of packers will be used everywhere that data is packed/unpacked when using this client, including web sockets. | |
Utility function used in the packing functions that determines if an object is a plain object or not. Because this is such a common operation when checking and serializing unknown objects, it's being exported as part of the API. | |
f pack | Packs a value recursively until it's JSON-compatible. Packers can be plugged
in to extend the accepted types beyond what Cav supports by default as well
as the packers registered with |
Packs a value into a type that is compatible with a Response BodyInit, making it easy to pack values for sending to an external host/client via HTTP. If a provided value is already compatible with BodyInit, it will be returned with an appropriate mime type, skipping the packing process. During packing, this function extends the default supported types to include Blobs and Files. If a Blob is encountered during packing, the resulting body will be a multipart FormData that encodes the shape of the input as well as the blobs that were encountered. Otherwise, a regular JSON string will be returned. Blobs and Files can be placed anywhere on the input value, even if they are nested. | |
Constructs a Packer. This simply returns the first argument, it's only used for type annotations. | |
Packs the value into a JSON string. This function is a one-liner: | |
Unpacks a value packed with | |
Unpacks a Request or Response object whose body was packed with | |
Unpacks the JSON string into the original value. Any packers used during packing (outside of registered packers and the Cav defaults) need to be provided here as well, or an error may be thrown. This function is a one-liner: | |
Registers the Packers to be used as defaults in addition to the library
defaults for the top-level packing functions. Falsy properties are skipped.
If any packer keys conflict with the packers that are already in use, an
error is thrown. Returns the input | |
Wraps a regular WebSocket with packing functionality and type support. |
Interfaces
Client type representing an Rpc endpoint. Uses the Rpc type definition to determine what the expected arguments and response types are. | |
Initializer arguments for constructing HttpErrors. | |
A group of functions used to recognize, pack, and unpack objects and special values that are not strings, basic numbers, booleans, or nulls into objects that are JSON compatible. | |
Cav's WebSocket wrapper interface. | |
Initializer options to use when upgrading a request into a web socket using
the |
Type Aliases
Type alias representing a Packer with any input or output type. Useful for type constraints. | |
Type that matches any socket. Useful for type constraints. | |
A Proxied function that wraps | |
Uses the RpcInit type imported from the server to determine what shape the arguments should be in when making requests to a given Rpc. | |
A Record of Packers. Packer keys are used to tag packed values on the output JSON, which is required in order to correctly unpack the value on the other side. | |
A Packer's |