{
  "name": "pullstream",
  "version": "0.4.1",
  "description": "A stream you can pull data from.",
  "main": "pullstream.js",
  "scripts": {
    "test": "nodeunit test"
  },
  "license": "MIT",
  "bugs": {
    "url": "https://github.com/nearinfinity/node-pullstream/issues"
  },
  "repository": {
    "type": "git",
    "url": "https://github.com/nearinfinity/node-pullstream.git"
  },
  "keywords": [
    "stream",
    "pull"
  ],
  "devDependencies": {
    "nodeunit": ">= 0.9.0 < 1",
    "stream-buffers": ">= 0.2.6 < 1",
    "async": ">= 0.9.0 <"
  },
  "dependencies": {
    "over": ">= 0.0.5 < 1",
    "readable-stream": "~1.0.31",
    "setimmediate": ">= 1.0.2 < 2",
    "slice-stream": ">= 1.0.0 < 2"
  },
  "readme": "pullstream [![Build Status](https://travis-ci.org/EvanOxfeld/node-pullstream.png)](https://travis-ci.org/EvanOxfeld/node-pullstream)\n==========\n\nTired of getting a firehose worth of data from your streams. This module is here to save the day. PullStream allows\nyou to pull data when you want and as much as you want.\n\n## Quick Examples\n\n```javascript\nvar PullStream = require('pullstream');\nvar fs = require('fs');\n\nvar ps = new PullStream();\nvar loremIpsumStream = fs.createReadStream('loremIpsum.txt');\nvar outputStream = fs.createWriteStream(path.join(__dirname, 'loremIpsum.out'));\n\nloremIpsumStream.pipe(ps);\n\n// pull 5 bytes\nps.pull(5, function(err, data) {\n  console.log(data.toString('utf8'));\n\n  //synchronously pull 1000 bytes or howevery many bytes are available\n  var bytes = ps.pullUpTo(1000);\n\n  // pipe the next 100 to a file\n  ps.pipe(100, outputStream).on('end', function () {\n    console.log('all done');\n  });\n});\n```\n\n# API Index\n\n## PullStream\n * [pull](#pullStreamPull)\n * [pullUpTo](#pullStreamPullUpTo)\n * [pipe](#pullStreamPipe)\n * [drain](#pullStreamDrain)\n * [write](#pullStreamWrite)\n * [end](#pullStreamEnd)\n * [prepend](#pullStreamPrepend)\n\n# API Documentation\n\n<a name=\"pullStream\"/>\n## PullStream\n\n<a name=\"pullStreamPull\" />\n### ps.pull([number], callback)\n\nCalls a callback when the specified number of bytes are ready. If no number is specified pull will read until the end\nof the input stream.\n\n__Arguments__\n\n* number (optional) - Number of bytes to wait for. If not specified reads to the end of input stream.\n* callback(err, data) - Callback called when the bytes are ready. data is a buffer containing the bytes.\n\n__Example__\n\n```javascript\nvar ps = new PullStream();\n\nps.pull(5, function(err, data) {\n  console.log(data.toString('utf8'));\n});\n```\n\n<a name=\"pullStreamPullUpTo\" />\n### ps.pullUpTo([number])\n\nSynchronously returns the specified number of bytes or however many bytes are available from the input stream. If no\nnumber is specified pullUpTo will return however many bytes are available from the input stream.\n\n__Arguments__\n\n* number (optional) - Number of bytes to read from the input stream.\n\n__Example__\n\n```javascript\nvar ps = new PullStream();\n\nvar data = ps.pullUpTo(1000);\nconsole.log(data.toString('utf8'));\n```\n\n<a name=\"pullStreamPipe\" />\n### ps.pipe([number], destStream)\n\nPipes the specified number of bytes to destStream. If a number is not specified pipe will pipe the remainder\nof the input stream to destStream. Back-pressure is properly managed.\n\n__Arguments__\n\n* number (optional) - Number of bytes to pipe. If not specified pipe the rest of input stream.\n* destStream - The stream to pipe data to.\n\n__Returns__\n\nReturns destStream.\n\n__Example__\n\n```javascript\nvar ps = new PullStream();\nvar outputStream = fs.createWriteStream(path.join(__dirname, 'loremIpsum.out'));\n\nps.pipe(100, out).on('end', function() {\n  console.log('done with pipe');\n});\n```\n\n<a name=\"pullStreamDrain\" />\n### ps.drain(number, callback)\n\nConsume the specified number of bytes and send them to nowhere. Also drains from upstream as necessary if the specified\nnumber of bytes is less than the length of the pull stream's internal buffer.\n\n__Example__\n\n```javascript\nvar ps = new PullStream();\n\nps.drain(5, function(err) {\n  console.log('5 bytes removed from pull stream');\n});\n```\n\n<a name=\"pullStreamWrite\" />\n### ps.write(data, [encoding])\n\nWrites data to input side of a pull stream.\n\n__Arguments__\n\n* data - Buffer or string to write to the input side of the pull stream.\n* encoding (optional) - Encoding to use if data is a string. If not specified 'utf8' is used.\n\n__Example__\n\n```javascript\nvar ps = new PullStream();\n\nps.pull(5, function(err, data) {\n  console.log(data.toString('ascii'));\n});\n\nps.write('Hello World', 'ascii');\n```\n\n<a name=\"pullStreamEnd\" />\n### ps.end()\n\nManually ends a pull stream.\n\n__Example__\n\n```javascript\nvar ps = new PullStream();\n\nps.pull(5, function(err, data) {\n  console.log(data.toString('utf8'));\n});\n\nps.write('Hello World');\nps.end();\n```\n\n<a name=\"pullStreamPrepend\" />\n### ps.prepend()\n\nWrites data to the front of the input side of a pull stream.\n\n__Example__\n\n```javascript\nvar ps = new PullStream();\n\nps.pull(11, function(err, data) {\n  console.log(data.toString());\n});\n\nps.write('World');\nps.prepend('Hello ');\nps.end();\n```\n\n## License\n\n(The MIT License)\n\nCopyright (c) 2012 - 2013 Near Infinity Corporation\n\nPermission is hereby granted, free of charge, to any person obtaining\na copy of this software and associated documentation files (the\n\"Software\"), to deal in the Software without restriction, including\nwithout limitation the rights to use, copy, modify, merge, publish,\ndistribute, sublicense, and/or sell copies of the Software, and to\npermit persons to whom the Software is furnished to do so, subject to\nthe following conditions:\n\nThe above copyright notice and this permission notice shall be\nincluded in all copies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND,\nEXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF\nMERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND\nNONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE\nLIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION\nOF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION\nWITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.\n\n",
  "readmeFilename": "README.md",
  "homepage": "https://github.com/nearinfinity/node-pullstream",
  "_id": "pullstream@0.4.1",
  "_shasum": "d6fb3bf5aed697e831150eb1002c25a3f8ae1314",
  "_from": "pullstream@>= 0.4.1 < 1",
  "_resolved": "https://registry.npm.taobao.org/pullstream/download/pullstream-0.4.1.tgz"
}
