Skip to content

liquidz/deno-bencode

Repository files navigation

deno-bencode

deno.land GitHub Actions for test workflow

Bencode decoder/encode for Deno

Decode

// Decode String
await bencode.decode("d3:fooli123ed3:bar3:bazeee") // => {foo: [123, {bar: "baz"}]}

// Decode with Stream
const src = await Deno.open("./test_input.txt");
const stream = src.readable.pipeThrough(new bencode.Uint8ArrayToBencodeStream())
for await (const v of stream) {
  console.log(v);
}

Encode

// Encode String
bencode.encode({foo: [123, {bar: "baz"}]}) // => "d3:fooli123ed3:bar3:bazeee"

License

Copyright (c) 2021-2024 Masashi Iizuka

Distributed under the MIT License.