{
  "name": "bncode",
  "version": "0.2.3",
  "description": "bittorrent bencoding and decoding.",
  "author": {
    "name": "Tim Becker",
    "email": "tim.becker@kuriositaet.de"
  },
  "main": "./bencode.js",
  "repository": {
    "type": "git",
    "url": "git://github.com/a2800276/bencode.js.git"
  },
  "scripts": {
    "test": "node test/test.js"
  },
  "readme": "[![build status](https://secure.travis-ci.org/a2800276/bencode.js.png)](http://travis-ci.org/a2800276/bencode.js)\n# bencoding for JS (node.js)\n\n\nThis is a small library to encode and decode bencoded (bittorrent) stuff. \nBencoding is specified [here](http://www.bittorrent.org/beps/bep_0003.html).\n\n\n## Get & Install\n\ngithub repository is [here](https://github.com/a2800276/bencode.js)\n\nInstallable via npm (npm package name is **bncode**, note spelling!):\n\n    npm install bncode\n\n\n## Encoding\n\nEncoding works as follows:\n\n    var benc  = require(\"bencode\"),\n        exmp = {}\n \n    exmp.bla = \"blup\"\n    exmp.foo = \"bar\"\n    exmp.one = 1\n    exmp.woah = {}\n    exmp.woah.arr = []\n    exmp.woah.arr.push(1)\n    exmp.woah.arr.push(2)\n    exmp.woah.arr.push(3)\n    exmp.str = new Buffer(\"Buffers work too\")\n \n    var bencBuffer = benc.encode(exmp)\n \n    // d3:bla4:blup3:foo3:bar3:onei1e4:woahd3:arr \\\n    // li1ei2ei3eee3:str16:Buffers work tooe\n\n\n\n## Decoding\n\nDecoding will work progressively, e.g. if you're receiving partial\nbencoded strings on the network:\n\n    var benc = require(\"bencode\"),\n        buf  = null\n \n    decoder = new bencode.decoder()\n    while (buf = receiveData()) {\n      decoder.decode(buf)\n    }\n    \n    log(decoder.result())\n\n\nOr \"all in one\"\n\n    var benc = require(\"bencode\"),\n        buf  = getBuffer(),\n        dec  = benc.decode(buf)\n \n    log(dec.bla)\n\n\nThere are some subtleties concerning bencoded strings. These are\ndecoded as Buffer objects because they are just strings of raw bytes\nand as such would wreak havoc with multi byte strings in javascript.\n\nThe exception to this is strings appearing as keys in bencoded\ndicts. These are decoded as Javascript Strings, as they should always\nbe strings of (ascii) characters and if they weren't decoded as JS\nStrings, dict's couldn't be mapped to Javascript objects.\n\n\n## Mapping bencoding to Javascript\n\n    \n     +----------------------------------------------------+\n     |                |                                   |\n     |  Bencoded      |    Javascript                     |\n     |====================================================|\n     |  Strings       |    node Buffers, unless they are  |\n     |                |    Dictionary keys, in which case |\n     |                |    they become Javascript Strings |\n     |----------------+-----------------------------------|\n     |  Integers      |    Number                         |\n     |----------------+-----------------------------------|\n     |  Lists         |    Array                          |\n     |----------------+-----------------------------------|\n     |  Dictionaries  |    Object                         |\n     |                |                                   |\n     +----------------------------------------------------+\n\n\n## Mapping Javascript to bencoding\n\nThe code makes a best effort to encode Javascript to bencoding. If you stick to basic \ntypes (Arrays, Objects with String keys and basic values, Strings, Buffers and Numbers) \nyou should encounter suprises. Expect surprises (mainly not being able to round-trip \nencode/decode) if you encode fancy data-types.\n\n\n## Author\n\nbencode.js was written by Tim Becker (tim.becker@kuriositaet.de) I can be reached via \nemail or (preferably) submit a bug to the github repository.\n\n\n## Thanks\n\nRoly Fentanes (fent) for bug reports.\n\n\n## License\n\nMIT, see `LICENSE`\n",
  "readmeFilename": "README.md",
  "bugs": {
    "url": "https://github.com/a2800276/bencode.js/issues"
  },
  "homepage": "https://github.com/a2800276/bencode.js",
  "_id": "bncode@0.2.3",
  "_shasum": "37f851dc8e47188a83fbc0f6fa4775cacc9a3296",
  "_from": "bncode@^0.2.3",
  "_resolved": "https://registry.npmjs.org/bncode/-/bncode-0.2.3.tgz"
}
