Skip to main content
Module

x/bencodex/mod.ts>Dictionary

An alternative take on implementing Bencodex in TypeScript/JavaScript
Latest
interface Dictionary
implements Iterable<readonly [Key, Value]>
import { type Dictionary } from "https://deno.land/x/bencodex@0.2.2/mod.ts";

Represents a Bencodex dictionary. It basically behaves like a read-only Map<Key, Value>, but it is not necessarily a Map instance.

Properties

readonly
size: number

The number of key-value pairs in this dictionary.

Methods

get(key: Key): Value | undefined

Gets the value associated with the given key.

has(key: Key): boolean

Checks if the given key is present in this dictionary.

keys(): Iterable<Key>

Gets an iterable object which iterates over the keys in this dictionary.

values(): Iterable<Value>

Gets an iterable object which iterates over the values in this dictionary.

entries(): Iterable<readonly [Key, Value]>

Gets an iterable object which iterates over the key-value pairs in this dictionary. This method is equivalent to Dictionary[Symbol.iterator]().

forEach(callback: (
value: Value,
key: Key,
dictionary: Dictionary,
) => void
, thisArg?: unknown
): void

Calls the given callback function for each key-value pair in this dictionary.

[[Symbol.iterator]](): Iterator<readonly [Key, Value]>

Gets an iterator which iterates over the key-value pairs in this dictionary. This method is equivalent to Dictionary.entries().