https://github.com/disjukr/bencodex
bencodex
https://github.com/disjukr/bencodex
Last synced: about 1 month ago
JSON representation
bencodex
- Host: GitHub
- URL: https://github.com/disjukr/bencodex
- Owner: disjukr
- Created: 2018-10-29T19:34:07.000Z (over 6 years ago)
- Default Branch: main
- Last Pushed: 2022-10-06T08:49:38.000Z (over 2 years ago)
- Last Synced: 2025-03-25T20:33:07.998Z (2 months ago)
- Language: TypeScript
- Homepage: https://github.com/planetarium/bencodex
- Size: 16.6 KB
- Stars: 8
- Watchers: 3
- Forks: 2
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# bencodex
## requirements
- nodejs 11 (or 10 with [Array.prototype.flat](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/flat) polyfill)
- typescript 3.2 (bigint)## install
```sh
npm install bencodex
```## usage
```js
const { encode, decode } = require('bencodex');console.log(encode({ a: 1, b: 2 }));
// =>console.log(encode({ a: 1, b: 2 }).toString());
// => du1:ai1eu1:bi2eeconsole.log(decode(Buffer.from('du1:ai1eu1:bi2ee')));
// => Map { 'a' => 1n, 'b' => 2n }
```