Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

bencode-js

Package Overview
Dependencies
Maintainers
1
Versions
10
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

bencode-js

JavaScript solution for implmenting the encoding and decoding of the Bencode format

  • 0.0.8
  • latest
  • Source
  • npm
  • Socket score

Version published
Maintainers
1
Created
Source

Bencode-js

Zero dependency JavaScript solution for implementing the encoding and decoding of the Bencode format. Works in both browser and commonjs environments.

  • BitTorrent Specification
  • Bencode

Install

npm install bencode-js

For the browser, simply copy either the compressed or uncompressed file into your app and include it on your web page.

Usage

CommonJS environments:

Bencode = require('bencode-js')
Bencode.decode(...)
Bencode.encode(...)

In the browser the object is available globally as window.Bencode.

Bencode#encode(object)

object is either a String, Number, Array, or Object.

Bencode.encode("string")         // => "6:string"
Bencode.encode(123)              // => "i123e"
Bencode.encode(["str", 123])     // => "l3:stri123ee"
Bencode.encode({ key: "value" }) // => "d3:key5:valuee"

Bencode#decode(string)

string is a Bencoded string.

Bencode.decode("d3:key5:valuee") // => { key: "value" }

Keywords

FAQs

Package last updated on 23 Jan 2017

Did you know?

Socket

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.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc