{"maintainers":[{"name":"sindresorhus","email":"sindresorhus@gmail.com"}],"keywords":["buffer","stream","streams","transform","first","chunk","size","min","minimum"],"dist-tags":{"latest":"2.0.0"},"author":{"name":"Sindre Sorhus","email":"sindresorhus@gmail.com","url":"sindresorhus.com"},"description":"Transform the first chunk in a stream","readme":"# first-chunk-stream [![Build Status](https://travis-ci.org/sindresorhus/first-chunk-stream.svg?branch=master)](https://travis-ci.org/sindresorhus/first-chunk-stream)\n\n> Buffer and transform the n first bytes of a stream\n\n\n## Install\n\n```\n$ npm install --save first-chunk-stream\n```\n\n\n## Usage\n\n```js\nconst fs = require('fs');\nconst concatStream = require('concat-stream');\nconst firstChunkStream = require('first-chunk-stream');\n\n// unicorn.txt => unicorn rainbow\nfs.createReadStream('unicorn.txt')\n\t.pipe(firstChunkStream({chunkLength: 7}, function (chunk, enc, cb) {\n\t\tthis.push(chunk.toUpperCase());\n\t\tcb();\n\t}))\n\t.pipe(concatStream(function (data) {\n\t\tif (data.length < 7) {\n\t\t\tthrow new Error('Couldn\\'t get the minimum required first chunk length');\n\t\t}\n\n\t\tconsole.log(data);\n\t\t//=> 'UNICORN rainbow'\n\t}));\n```\n\n\n## API\n\n### firstChunkStream([options], transform)\n\nReturns a `FirstChunkStream` instance.\n\n#### options\n\nThe options object is passed to the [`Duplex` stream](https://nodejs.org/api/stream.html#stream_class_stream_duplex) constructor allowing you to customize your stream behavior. In addition you can specify the following option:\n\n##### chunkLength\n\nType: `number`\n\nHow many bytes you want to buffer.\n\n#### transform(chunk, encoding, callback)\n\nType: `function`\n\nThe function that gets the required `options.chunkLength` bytes.\n\nNote that the buffer can have a smaller length than the required one. In that case, it will be due to the fact that the complete stream contents has a length less than the `òptions.chunkLength` value. You should check for this yourself if you strictly depend on the length.\n\n\n## License\n\nMIT © [Sindre Sorhus](http://sindresorhus.com)\n","repository":{"type":"git","url":"git+https://github.com/sindresorhus/first-chunk-stream.git"},"bugs":{"url":"https://github.com/sindresorhus/first-chunk-stream/issues"},"license":"MIT","versions":{"0.1.0":{"name":"first-chunk-stream","version":"0.1.0","description":"Transform the first chunk in a stream","license":"MIT","repository":{"type":"git","url":"git://github.com/sindresorhus/first-chunk-stream"},"author":{"name":"Sindre Sorhus","email":"sindresorhus@gmail.com","url":"http://sindresorhus.com"},"engines":{"node":">=0.10.0"},"scripts":{"test":"mocha"},"files":["index.js"],"keywords":["buffer","stream","streams","transform","first","chunk","size","min","minimum"],"devDependencies":{"concat-stream":"^1.4.5","mocha":"*"},"gitHead":"79ca900b4d31074448dc7767eae79f1e605dca20","bugs":{"url":"https://github.com/sindresorhus/first-chunk-stream/issues"},"homepage":"https://github.com/sindresorhus/first-chunk-stream","_id":"first-chunk-stream@0.1.0","_shasum":"755d3ec14d49a86e3d2fcc08beead5c0ca2b9c0a","_from":".","_npmVersion":"1.4.13","_npmUser":{"name":"sindresorhus","email":"sindresorhus@gmail.com"},"maintainers":[{"name":"sindresorhus","email":"sindresorhus@gmail.com"}],"dist":{"shasum":"755d3ec14d49a86e3d2fcc08beead5c0ca2b9c0a","tarball":"http://nexus.dui88.com:8081/nexus/content/repositories/npm-registry/first-chunk-stream/-/first-chunk-stream-0.1.0.tgz"},"directories":{}},"1.0.0":{"name":"first-chunk-stream","version":"1.0.0","description":"Transform the first chunk in a stream","license":"MIT","repository":{"type":"git","url":"https://github.com/sindresorhus/first-chunk-stream"},"author":{"name":"Sindre Sorhus","email":"sindresorhus@gmail.com","url":"http://sindresorhus.com"},"engines":{"node":">=0.10.0"},"scripts":{"test":"mocha"},"files":["index.js"],"keywords":["buffer","stream","streams","transform","first","chunk","size","min","minimum"],"devDependencies":{"concat-stream":"^1.4.5","mocha":"*"},"gitHead":"8b0b1750edcc30fa2b2071245198181e925be619","bugs":{"url":"https://github.com/sindresorhus/first-chunk-stream/issues"},"homepage":"https://github.com/sindresorhus/first-chunk-stream","_id":"first-chunk-stream@1.0.0","_shasum":"59bfb50cd905f60d7c394cd3d9acaab4e6ad934e","_from":".","_npmVersion":"1.4.21","_npmUser":{"name":"sindresorhus","email":"sindresorhus@gmail.com"},"maintainers":[{"name":"sindresorhus","email":"sindresorhus@gmail.com"}],"dist":{"shasum":"59bfb50cd905f60d7c394cd3d9acaab4e6ad934e","tarball":"http://nexus.dui88.com:8081/nexus/content/repositories/npm-registry/first-chunk-stream/-/first-chunk-stream-1.0.0.tgz"},"directories":{}},"2.0.0":{"name":"first-chunk-stream","version":"2.0.0","description":"Transform the first chunk in a stream","license":"MIT","repository":{"type":"git","url":"git+https://github.com/sindresorhus/first-chunk-stream.git"},"author":{"name":"Sindre Sorhus","email":"sindresorhus@gmail.com","url":"sindresorhus.com"},"engines":{"node":">=0.10.0"},"scripts":{"test":"xo && mocha","cover":"istanbul cover --report html _mocha -- test.js -R spec -t 5000"},"files":["index.js"],"keywords":["buffer","stream","streams","transform","first","chunk","size","min","minimum"],"dependencies":{"readable-stream":"^2.0.2"},"devDependencies":{"istanbul":"^0.3.19","mocha":"*","mocha-lcov-reporter":"0.0.2","streamtest":"^1.2.1","xo":"*"},"gitHead":"867c900661f90b4f50d1b2494f714f80933fc696","bugs":{"url":"https://github.com/sindresorhus/first-chunk-stream/issues"},"homepage":"https://github.com/sindresorhus/first-chunk-stream#readme","_id":"first-chunk-stream@2.0.0","_shasum":"1bdecdb8e083c0664b91945581577a43a9f31d70","_from":".","_npmVersion":"2.14.3","_nodeVersion":"4.1.0","_npmUser":{"name":"sindresorhus","email":"sindresorhus@gmail.com"},"dist":{"shasum":"1bdecdb8e083c0664b91945581577a43a9f31d70","tarball":"http://nexus.dui88.com:8081/nexus/content/repositories/npm-registry/first-chunk-stream/-/first-chunk-stream-2.0.0.tgz"},"maintainers":[{"name":"sindresorhus","email":"sindresorhus@gmail.com"}],"directories":{}}},"name":"first-chunk-stream","time":{"modified":"2015-09-20T16:31:11.197Z","created":"2014-05-25T15:47:09.711Z","0.1.0":"2014-05-25T15:47:09.711Z","1.0.0":"2014-08-14T09:06:30.958Z","2.0.0":"2015-09-20T16:31:11.197Z"},"readmeFilename":"readme.md","homepage":"https://github.com/sindresorhus/first-chunk-stream#readme"}