class RecordView
implements Dictionary
import { RecordView } from "https://deno.land/x/bencodex@0.2.2/src/dict.ts";
A view of a RecordValue that implements Dictionary. It is a handy way to construct a Dictionary using JavaScript's object literal syntax.
Examples
Constructing a simple dictionary
Constructing a simple dictionary
const dict = new RecordView({
foo: [1n, 2n, 3n],
bar: {
baz: "qux",
quux: true,
},
});
The above code is mostly equivalent to the following code:
const dict = new BencodexDictionary([
["foo", [1n, 2n, 3n]],
[
"bar",
new BencodexDictionary([
["baz", "qux"],
["quux", true],
]),
],
])
Constructors
new
RecordView(record: RecordValue, keyEncoding: "text" | "utf8")Creates a new RecordView instance.
Methods
forEach(callback: () => void, thisArg?: unknown): void
{@inheritDoc Dictionary.forEach}
[Symbol.for("Deno.customInspect")](inspect: (_: unknown, options: unknown) => string, options: { compact: boolean; depth: number; sorted: boolean; trailingComma: boolean; }): string
[Symbol.for("nodejs.util.inspect.custom")](): string
_: number,
options: { compact: number | boolean; depth: number; sorted: boolean; },
inspect: (_: unknown, options: unknown) => string,
[Symbol.iterator](): Iterator<[Key, Value]>
Gets an iterator which iterates over the key-value pairs in this
dictionary. This method is equivalent to Dictionary.entries()
.