{
  "name": "bncode",
  "version": "0.5.3",
  "description": "bittorrent bencoding and decoding.",
  "author": {
    "name": "Tim Becker",
    "email": "tim.becker@kuriositaet.de"
  },
  "contributors": [
    {
      "name": "Feross Aboukhadijeh",
      "email": "feross@feross.org"
    },
    {
      "name": "Roly Fentanes",
      "email": "roly426@gmail.com"
    },
    {
      "name": "Patrick Williams",
      "email": "patrick@bittorrent.com"
    },
    {
      "name": "Clark Fischer",
      "email": "clark.fischer@gmail.com"
    }
  ],
  "main": "./bncode.js",
  "repository": {
    "type": "git",
    "url": "git://github.com/a2800276/bncode.git"
  },
  "scripts": {
    "test": "node test/test.js"
  },
  "dependencies": {},
  "readme": "[![build status](https://secure.travis-ci.org/a2800276/bncode.png)](http://travis-ci.org/a2800276/bncode)\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/bncode)\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(\"bncode\"),\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(\"bncode\"),\n        buf  = null\n \n    decoder = new benc.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(\"bncode\"),\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 shouldn't encounter suprises. Expect surprises (mainly not being able to round-trip \nencode/decode) if you encode fancy data-types.\n\n\n## Author\n\nbncode 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\n* Roly Fentanes (fent) for bug reports.\n* Clark Fischer (clarkf)\n* The fine folks at Travis.\n* Patrick Williams\n* Feross Aboukhadijeh\n\n\n## License\n\nMIT, see `LICENSE`\n",
  "readmeFilename": "README.md",
  "bugs": {
    "url": "https://github.com/a2800276/bncode/issues"
  },
  "homepage": "https://github.com/a2800276/bncode",
  "_id": "bncode@0.5.3",
  "dist": {
    "shasum": "af6fe1cd255c3421c45b98b5bfad0d6a8407b86a"
  },
  "_resolved": "https://registry.npmjs.org/bncode/-/bncode-0.5.3.tgz",
  "_from": "bncode@^0.5.2"
}
