Skip to main content
Module

x/cav/pack.ts>packBody

A server framework for Deno
Go to Latest
function packBody
import { packBody } from "https://deno.land/x/cav@0.0.8/pack.ts";

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.

Parameters

value: unknown
optional
packers: Packers

Returns

{ body: BodyInit; mime: string; }