Socket
Socket
Sign inDemoInstall

bencode-js

Package Overview
Dependencies
0
Maintainers
1
Versions
10
Alerts
File Explorer

Advanced tools

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


Version published
Weekly downloads
12
decreased by-33.33%
Maintainers
1
Install size
19.6 kB
Created
Weekly downloads
 

Readme

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

Last updated on 23 Jan 2017

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.

Install

Related posts

SocketSocket SOC 2 Logo

Product

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

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc