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

x/bencodex/src/encoder.ts>estimateSize

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

Estimates the byte size of the given value in Bencodex.

Note that this function does not guarantee the exact size of the value when encoded in Bencodex, but it is guaranteed to be greater than or equal to the actual size. In particular, this function does not take into account the size of the dictionary with duplicate keys.

Parameters

value: Value

A Bencodex value to estimate the size.

optional
options: SizeEstimationOptions = [UNSUPPORTED]

Options for size estimation.

Returns

number

The estimated byte size of the given value.