import { encode } from "https://deno.land/x/bencodex@0.2.2/src/encoder.ts";
Encodes a Bencodex value and returns the encoded bytes.
This function allocates a new buffer and returns the encoded bytes. If you want to encode a value into a pre-allocated buffer, use encodeInto instead.
Examples
Encoding a Bencodex list
Encoding a Bencodex list
const encoded = encode([true, "spam"]);
console.log(encoded);
// Uint8Array(10) [ 0x6c, 0x74, 0x75, 0x34, 0x3a, 0x73, 0x70,
// 0x61, 0x6d, 0x65 ]
Parameters
value: Value
A Bencodex value to encode.
optional
options: EncodingOptions = [UNSUPPORTED]Encoding options.