![require(esm) Backported to Node.js 20, Paving the Way for ESM-Only Packages](https://cdn.sanity.io/images/cgdhsj6q/production/be8ab80c8efa5907bc341c6fefe9aa20d239d890-1600x1097.png?w=400&fit=max&auto=format)
Security News
require(esm) Backported to Node.js 20, Paving the Way for ESM-Only Packages
require(esm) backported to Node.js 20, easing the transition to ESM-only packages and reducing complexity for developers as Node 18 nears end-of-life.
Library for decoding and encoding bencoded data.
Compliant with the BitTorrent bencoding specification.
Fast and easy to use.
Written in TypeScript.
Fully tested with 100% code coverage.
Without dependencies.
npm | yarn |
---|---|
npm install --save bencodec | yarn add bencodec |
typescript | javascript |
---|---|
import bencodec from 'bencodec' | const bencodec = require('bencodec') |
To convert byte strings to strings pass true
as the second parameter.
bencodec.decode( 'd3:bar4:spam3:fooi42ee' );
// { bar: <Buffer 73 70 61 6d>, foo: 42 }
bencodec.decode( 'd3:bar4:spam3:fooi42ee', true );
// { bar: 'spam', foo: 42 }
bencodec.decode( Buffer.from('d3:bar4:spam3:fooi42ee'), true );
// { bar: 'spam', foo: 42 }
By default method encode will return the byte string.
Pass true
as the second parameter to 'stringify' result.
bencodec.encode({ bar: 'spam', foo: 42 });
// <Buffer 64 33 ... 65 65>
bencodec.encode({ bar: 'spam', foo: 42 }, true);
// 'd3:bar4:spam3:fooi42ee'
npm test
This project is licensed under the MIT License - see the LICENSE file for details.
FAQs
Library for decoding and encoding bencode data
The npm package bencodec receives a total of 119 weekly downloads. As such, bencodec popularity was classified as not popular.
We found that bencodec demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
require(esm) backported to Node.js 20, easing the transition to ESM-only packages and reducing complexity for developers as Node 18 nears end-of-life.
Security News
PyPI now supports iOS and Android wheels, making it easier for Python developers to distribute mobile packages.
Security News
Create React App is officially deprecated due to React 19 issues and lack of maintenance—developers should switch to Vite or other modern alternatives.