Important: This documentation covers Yarn 1 (Classic).
For Yarn 2+ docs and migration guide, see yarnpkg.com.

Package detail

dht-bencode

stbuehler301deprecated0.1.2

Package no longer supported. Contact Support at https://www.npmjs.com/support for more info.

bencoding with Buffers instead of strings

readme

dht-bencode

bencode with Buffer()s from nodejs (as it is binary data javascript strings are not a good way to handle it)

install

npm install dht-bencode

usage

var bencode = require('dht-bencode');

bencode.bencode({ t: 'ab' }).toString(); // should result in "d1:t2:abe"
bencode.bdecode("d1:t2:abe"); // should result in { t: <Buffer 61 62> }

// you can also tell bdecode to ignore padding after the object
bencode.bdecode("7:contentpadding", true); // should result in { <Buffer("content")> }
// if you don't allow it, it will raise a bencode.PaddingError object (which has the
// parsed object in the .object property)