Skip to main content
Deno 2 is finally here 🎉️
Learn more
Module

x/bencodex/src/encoder.ts>SizeEstimationOptions

An alternative take on implementing Bencodex in TypeScript/JavaScript
Latest
interface SizeEstimationOptions
import { type SizeEstimationOptions } from "https://deno.land/x/bencodex@0.2.2/src/encoder.ts";

Options for size estimation functions, estimateSize and estimateKeySize.

Properties

optional
accuracy: "bestEffort" | "fastGuess"

The strategy to deal with slow-to-estimate values.

The "bestEffort", which is the default, will try to estimate the size of the value as * accurately as possible, but it may take longer time.

The "fastGuess" will return a fast but inaccurate size estimation; it is guaranteed to be greater than or equal to the actual size, but it never be less than the actual size, so that it is safe to allocate a buffer with the returned size.