{
  "name": "torrent-stream",
  "version": "0.13.4",
  "description": "Low level streaming torrent client that exposes files as node.js streams and downloads pieces based on demand",
  "repository": {
    "type": "git",
    "url": "git://github.com/mafintosh/torrent-stream.git"
  },
  "scripts": {
    "test": "tap test/*.js"
  },
  "dependencies": {
    "bitfield": "^0.1.0",
    "bittorrent-dht": "^1.0.0",
    "bittorrent-tracker": "^1.5.0",
    "bncode": "^0.5.2",
    "compact2string": "^1.2.0",
    "end-of-stream": "^0.1.4",
    "hat": "0.0.3",
    "ip": "^0.3.0",
    "magnet-uri": "^2.0.1",
    "mkdirp": "^0.3.5",
    "parse-torrent": "^1.4.0",
    "peer-wire-swarm": "^0.9.0",
    "random-access-file": "^0.3.1",
    "rimraf": "^2.2.5",
    "thunky": "^0.1.0"
  },
  "devDependencies": {
    "tap": "^0.4.8",
    "fs-extra": "^0.9.1"
  },
  "readme": "# torrent-stream\n\nThe streaming torrent engine that [peerflix](https://github.com/mafintosh/peerflix) uses\n\n\tnpm install torrent-stream\n\n## How can I help?\n\n1. Open issues on things that are broken\n2. Fix open issues by sending PRs\n3. Add documentation\n\n## Usage\n\ntorrent-stream is a node module that allows you to access files inside a torrent as node streams.\n\n``` js\nvar torrentStream = require('torrent-stream');\n\nvar engine = torrentStream('magnet:my-magnet-link');\n\nengine.on('ready', function() {\n\tengine.files.forEach(function(file) {\n\t\tconsole.log('filename:', file.name);\n\t\tvar stream = file.createReadStream();\n\t\t// stream is readable stream to containing the file content\n\t});\n});\n```\n\nYou can pass `start` and `end` options to stream to slice the file\n\n``` js\n// get a stream containing bytes 10-100 inclusive.\nvar stream = file.createReadStream({\n\tstart: 10,\n\tend: 100\n});\n```\n\nPer default no files are downloaded unless you create a stream to them.\nIf you want to fetch a file without creating a stream you should use the `file.select` and `file.deselect` methods.\n\nWhen you start torrent-stream it will connect to the torrent dht\nand fetch pieces according to the streams you create.\n\n## Full API\n\n#### `engine = torrentStream(magnet_link_or_buffer, opts)`\n\nCreate a new engine instance. Options can contain the following\n\n``` js\n{\n\tconnections: 100,     // Max amount of peers to be connected to.\n\tuploads: 10,          // Number of upload slots.\n\ttmp: '/tmp',          // Root folder for the files storage.\n\t                      // Defaults to '/tmp' or temp folder specific to your OS.\n\t                      // Each torrent will be placed into a separate folder under /tmp/torrent-stream/{infoHash}\n\tpath: '/tmp/my-file', // Where to save the files. Overrides `tmp`.\n\tverify: true,         // Verify previously stored data before starting\n\t                      // Defaults to true\n\tdht: true,            // Whether or not to use DHT to initialize the swarm.\n\t                      // Defaults to true\n\ttracker: true,        // Whether or not to use trackers from torrent file or magnet link\n\t                      // Defaults to true\n\ttrackers: [\n\t    'udp://tracker.openbittorrent.com:80',\n\t    'udp://tracker.ccc.de:80'\n\t],\n\t                      // Allows to declare additional custom trackers to use\n\t                      // Defaults to empty\n\tstorage: myStorage()  // Use a custom storage backend rather than the default disk-backed one\n}\n```\n\n#### `engine.on('ready', fn)`\n\nEmitted when the engine is ready to be used.\nThe files array will be empty until this event is emitted\n\n#### `engine.on('download', [piece-index])`\n\nEmitted everytime a piece has been downloaded and verified.\n\n#### `engine.on('upload', [piece-index, offset, length])`\n\nEmitted everytime a piece is uploaded.\n\n#### `engine.files[...]`\n\nAn array of all files in the torrent. See the file section for more info on what methods the file has\n\n#### `engine.destroy(cb)`\n\nDestroy the engine. Destroys all connections to peers\n\n#### `engine.connect('127.0.0.0:6881')`\n\nConnect to a peer manually\n\n#### `engine.disconnect('127.0.0.1:6881')`\n\nDisconnect from a peer manually\n\n#### `engine.block('127.0.0.1:6881')`\n\nDisconnect from a peer and add it to the blocklist, preventing any other connection to it\n\n#### `engine.remove([keep-pieces], cb)`\n\nCompletely remove all saved data for this torrent.\nOptionally, only remove cache and temporary data but keep downloaded pieces\n\n#### `engine.listen([port], cb)`\n\nListen for incoming peers on the specified port. Port defaults to `6881`\n\n#### `engine.swarm`\n\nThe attached [peer-wire-swarm](https://github.com/mafintosh/peer-wire-swarm) instance\n\n#### `file = engine.files[...]`\n\nA file in the torrent. They contains the following data\n\n``` js\n{\n\tname: 'my-filename.txt',\n\tpath: 'my-folder/my-filename.txt',\n\tlength: 424242\n}\n```\n\n#### `file.select()`\n\nSelects the file to be downloaded, but at a lower priority than streams.\nUseful if you know you need the file at a later stage.\n\n#### `file.deselect()`\n\nDeselects the file which means it won't be downloaded unless someone creates a stream to it\n\n#### `stream = file.createReadStream(opts)`\n\nCreate a readable stream to the file. Pieces needed by the stream will be prioritized highly.\nOptions can contain the following\n\n``` js\n{\n\tstart: startByte,\n\tend: endByte\n}\n```\n\nBoth `start` and `end` are inclusive\n\n## License\n\nMIT\n",
  "readmeFilename": "README.md",
  "bugs": {
    "url": "https://github.com/mafintosh/torrent-stream/issues"
  },
  "homepage": "https://github.com/mafintosh/torrent-stream",
  "_id": "torrent-stream@0.13.4",
  "_shasum": "341b705f55288cd4dd98c6d9869b14615d621f08",
  "_from": "torrent-stream@^0.13.2",
  "_resolved": "https://registry.npmjs.org/torrent-stream/-/torrent-stream-0.13.4.tgz"
}
