{"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":"anonymous","email":"sindresorhus@gmail.com"},"maintainers":[{"name":"anonymous","email":"sindresorhus@gmail.com"}],"dist":{"shasum":"755d3ec14d49a86e3d2fcc08beead5c0ca2b9c0a","tarball":"http://123.232.10.234:8212/nexus/content/groups/npm-public/first-chunk-stream/-/first-chunk-stream-0.1.0.tgz"},"directories":{},"contributors":[]},"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":"anonymous","email":"sindresorhus@gmail.com"},"maintainers":[{"name":"anonymous","email":"sindresorhus@gmail.com"}],"dist":{"shasum":"59bfb50cd905f60d7c394cd3d9acaab4e6ad934e","tarball":"http://123.232.10.234:8212/nexus/content/groups/npm-public/first-chunk-stream/-/first-chunk-stream-1.0.0.tgz"},"directories":{},"contributors":[]},"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":"anonymous","email":"sindresorhus@gmail.com"},"dist":{"shasum":"1bdecdb8e083c0664b91945581577a43a9f31d70","tarball":"http://123.232.10.234:8212/nexus/content/groups/npm-public/first-chunk-stream/-/first-chunk-stream-2.0.0.tgz"},"maintainers":[{"name":"anonymous","email":"sindresorhus@gmail.com"}],"directories":{},"contributors":[]},"3.0.0":{"name":"first-chunk-stream","version":"3.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":">=8"},"scripts":{"test":"xo && nyc ava && tsd"},"keywords":["buffer","stream","streams","transform","first","chunk","size","min","minimum"],"devDependencies":{"@types/node":"^12.0.0","ava":"^1.4.1","nyc":"^14.0.0","streamtest":"^1.2.1","tsd":"^0.7.3","xo":"^0.24.0"},"gitHead":"c34c62cbf812d3b7c034b4e82a6118c385be118a","bugs":{"url":"https://github.com/sindresorhus/first-chunk-stream/issues"},"homepage":"https://github.com/sindresorhus/first-chunk-stream#readme","_id":"first-chunk-stream@3.0.0","_nodeVersion":"8.16.0","_npmVersion":"6.9.0","_npmUser":{"name":"anonymous","email":"sindresorhus@gmail.com"},"dist":{"integrity":"sha512-LNRvR4hr/S8cXXkIY5pTgVP7L3tq6LlYWcg9nWBuW7o1NMxKZo6oOVa/6GIekMGI0Iw7uC+HWimMe9u/VAeKqw==","shasum":"06972a66263505ed82b2c4db93c1b5e078a6576a","tarball":"http://123.232.10.234:8212/nexus/content/groups/npm-public/first-chunk-stream/-/first-chunk-stream-3.0.0.tgz","fileCount":5,"unpackedSize":9658,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJc2CprCRA9TVsSAnZWagAAdzYP/0P767JdWWTRx28Mjyu4\nNfZXQVDLpEwRlzKi7aLZFviYNAheIAODBWuFcVnOdM5tUUzJcP50bMPvR6Y/\nPyFWn4TpvtTn/xcZ9J6YulFZ/POsw4LBoeAh4MQJ+/9Ev1W1qfAhKZ2jgUa0\nlSz1nuGVwtVl1MrNSWHnB8XBhGE7zuwuvglU6yfLnu6wiOC/xfMquSyVQpqO\nxFEFBfroC/bLCJXBRZzKvO5GRxCk9DyhvdbrO5a2FL5rdNY9E4Vnoa1fzjQJ\nLQIveSsN+f1v/080/Hij0I7i5lgkJbSitU5tBlK3MR3gd7Q7erRNuQyhGcoo\n7voeqC4rhFw8I+GDVvTcn0WQupp5Ui2Ll5TGcI5VOTkeyVeEY8jfAjCKKUjj\nOpGCMNhJlxv1Y7WHZKdotD7uKeOEzfSZTpTMFwWLHOkUix3WpKrN90QyN6nR\nv3pmfx0KK5A4Xc03hVD3GIAxrU2J8AO8aXSNdtgkG93sdKYrdM9j8OBeXgM+\nrnnPW9DqdIGo2dKwt7EBJMHuMtybrKgLUbZ6yOl2s6zczyX31WTjGPEYtTGz\npnuwUp5MdxjFNUhBx2ukbkU70xVs8CLpfSFGacvYB84jf5KaWEMvFeUln7So\nUPVC7HpQg4oND5IYawGbOFoa/kUneOvCIICPSVYjogVcw6JHNnEL9Mf0V7kC\nmhkT\r\n=XUyk\r\n-----END PGP SIGNATURE-----\r\n"},"maintainers":[{"name":"anonymous","email":"sindresorhus@gmail.com"}],"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/first-chunk-stream_3.0.0_1557670506283_0.4465839831807381"},"_hasShrinkwrap":false,"contributors":[]},"4.0.0":{"name":"first-chunk-stream","version":"4.0.0","description":"Buffer and transform the n first bytes of 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":">=8"},"scripts":{"test":"xo && nyc ava && tsd"},"keywords":["buffer","stream","streams","transform","first","chunk","size","min","minimum","bytes"],"devDependencies":{"@types/node":"^12.0.8","ava":"^2.1.0","nyc":"^14.0.0","streamtest":"^1.2.1","tsd":"^0.7.3","xo":"^0.24.0"},"gitHead":"0f40e3d18ac9527a5efeca2f5a9fe25297a243dc","bugs":{"url":"https://github.com/sindresorhus/first-chunk-stream/issues"},"homepage":"https://github.com/sindresorhus/first-chunk-stream#readme","_id":"first-chunk-stream@4.0.0","_nodeVersion":"8.16.0","_npmVersion":"6.9.0","_npmUser":{"name":"anonymous","email":"sindresorhus@gmail.com"},"dist":{"integrity":"sha512-8TOz/mJp7+zc2HN63vnJHotwceq4gQI1+/gdJVnJcG4dEB96oUxw7wV9We4QKjSFWUc/V0ADDfaGba5cDoG6EA==","shasum":"798e0b91a019a9421246ec4e4d25885c5d97912c","tarball":"http://123.232.10.234:8212/nexus/content/groups/npm-public/first-chunk-stream/-/first-chunk-stream-4.0.0.tgz","fileCount":5,"unpackedSize":10473,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJdAfntCRA9TVsSAnZWagAAlX4QAJTepXC83+To++MC5lgz\n1q+RW8dAkTVHbHJq3+bPFIGPf5tmeI9GBX+WNQTHmo/ZQnvb8KY1+JqVdCvQ\n5HN/6UZBvWLjZjBWdShquyij8YLsHbHl/sgzgdMmgvcSCWbnmciRzNkyPTmq\nL7wApYUI0JTeEnjAmyHp0oVnitmYZYOHqiWvv+roFlRV+RE5cYrnDK7cNadj\nQfTbN4hsBXRDga9RnbfcqX5QpWo1ZQUuWVJGBnvnG9ZbD40qqgPr73B4gYrh\ncjlf/SjTnx3zMZkGcNi7qyHb7Rj+xH8OGcBBO0rA2fnRoGMahfFVLJj9CojD\ngaGQJjAcI9U6f0NRMfIimnU6GL5k8j1mflbKYaltZCL4LXvGS4irt8z68YQO\nfjKoRzbpYZ23WX/soaKsp+T34e5sxHYVPSNv7ue99aj2kvwC5Pk9mTE5jDae\nd4bLqD7HcbBTtX7MfjIU6hMumvdVj1dTQyYil+W9hCD1JxYwGo7buMx4rySR\nojUargc+nAVhMIEV/p+Y16+6KKRO+87x5OFemITxeWq82aXFppuyPb7w8l6G\n4CClpmlh9s/DZzo2jD+BJ8yMgq8ACiItgKPGj2XyHGyIDVpjyZdeaxNkZ6qD\n5o7yEkgwPwIdnVQXiLBh3kMWDm23j/77PFbN0+7oZiXvjdBOujfqhxoyAiux\nq7Pb\r\n=kSqW\r\n-----END PGP SIGNATURE-----\r\n"},"maintainers":[{"name":"anonymous","email":"sindresorhus@gmail.com"}],"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/first-chunk-stream_4.0.0_1560410604833_0.02719108546276816"},"_hasShrinkwrap":false,"contributors":[]},"5.0.0":{"name":"first-chunk-stream","version":"5.0.0","description":"","license":"MIT","repository":{"type":"git","url":"git+https://github.com/sindresorhus/first-chunk-stream.git"},"funding":"https://github.com/sponsors/sindresorhus","author":{"name":"Sindre Sorhus","email":"sindresorhus@gmail.com","url":"https://sindresorhus.com"},"type":"module","exports":"./index.js","engines":{"node":"^12.20.0 || ^14.13.1 || >=16.0.0"},"scripts":{"test":"xo && nyc ava && tsd"},"keywords":["buffer","stream","streams","transform","first","chunk","size","minimum","bytes"],"devDependencies":{"@types/node":"^16.6.1","ava":"^3.15.0","nyc":"^15.1.0","streamtest":"^2.0.0","tsd":"^0.17.0","xo":"^0.44.0"},"gitHead":"91cd5d0cd51c796768f43cc7d6e314eff325460c","bugs":{"url":"https://github.com/sindresorhus/first-chunk-stream/issues"},"homepage":"https://github.com/sindresorhus/first-chunk-stream#readme","_id":"first-chunk-stream@5.0.0","_nodeVersion":"12.22.1","_npmVersion":"7.10.0","dist":{"shasum":"6089fd0add05b058ec0c122a21c0c1801d06d5ff","size":3605,"noattachment":false,"tarball":"http://123.232.10.234:8212/nexus/content/groups/npm-public/first-chunk-stream/-/first-chunk-stream-5.0.0.tgz"},"_npmUser":{"name":"anonymous","email":"sindresorhus@gmail.com"},"directories":{},"maintainers":[{"name":"anonymous","email":"sindresorhus@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/first-chunk-stream_5.0.0_1629063834702_0.9370822033374449"},"_hasShrinkwrap":false,"publish_time":1629063834847,"_cnpm_publish_time":1629063834847,"contributors":[]},"6.0.0":{"name":"first-chunk-stream","version":"6.0.0","description":"Buffer and transform the n first bytes of a stream","license":"MIT","repository":{"type":"git","url":"git+https://github.com/sindresorhus/first-chunk-stream.git"},"funding":"https://github.com/sponsors/sindresorhus","author":{"name":"Sindre Sorhus","email":"sindresorhus@gmail.com","url":"https://sindresorhus.com"},"type":"module","exports":"./index.js","engines":{"node":">=18"},"scripts":{"test":"xo && nyc ava && tsd"},"keywords":["buffer","stream","streams","transform","first","chunk","size","minimum","bytes"],"dependencies":{"uint8array-extras":"^0.5.0"},"devDependencies":{"@types/node":"^20.8.10","ava":"^3.15.0","nyc":"^15.1.0","streamtest":"^2.0.0","tsd":"^0.29.0","xo":"^0.56.0"},"xo":{"rules":{"ava/no-unknown-modifiers":"off"}},"types":"./index.d.ts","gitHead":"61daf303dc475af9a447d1024114411d3b26dd06","bugs":{"url":"https://github.com/sindresorhus/first-chunk-stream/issues"},"homepage":"https://github.com/sindresorhus/first-chunk-stream#readme","_id":"first-chunk-stream@6.0.0","_nodeVersion":"18.18.2","_npmVersion":"9.2.0","dist":{"integrity":"sha512-8Mw/j+usWmvKvAk2szboyX4GzsWRUe6em5PT4csJi3TIR7e+SMGb7gtsc3Vv/JeAEVW1VDosAV4llpMXpoROrA==","shasum":"e27cb13ac76ea974bfbf1e80a162ce5f83e8fcfd","tarball":"http://123.232.10.234:8212/nexus/content/groups/npm-public/first-chunk-stream/-/first-chunk-stream-6.0.0.tgz","fileCount":5,"unpackedSize":10579,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCIFVLCEH+YTR+ejUIeP4RiSpkRa9RK3nJB/6rElwXKtcaAiA7dEFf/sPNvV1YL5zuBZ2n7Ccl2pRLprSiIP97OVsk7g=="}]},"_npmUser":{"name":"anonymous","email":"sindresorhus@gmail.com"},"directories":{},"maintainers":[{"name":"anonymous","email":"sindresorhus@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/first-chunk-stream_6.0.0_1698849039904_0.1167903385117608"},"_hasShrinkwrap":false,"contributors":[]}},"dist-tags":{"latest":"6.0.0"},"name":"first-chunk-stream","time":{"modified":"2024-06-19T16:30:16.800Z","created":"2022-01-26T13:12:43.765Z","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","3.0.0":"2019-05-12T14:15:06.570Z","4.0.0":"2019-06-13T07:23:24.939Z","5.0.0":"2021-08-15T21:43:54.847Z","6.0.0":"2023-11-01T14:30:40.058Z"},"readme":"# first-chunk-stream\n\n> Buffer and transform the n first bytes of a stream\n\n## Install\n\n```sh\nnpm install first-chunk-stream\n```\n\n## Usage\n\n```js\nimport fs from 'node:fs';\nimport getStream from 'get-stream';\nimport FirstChunkStream from 'first-chunk-stream';\nimport {uint8ArrayToString} from 'uint8array-extras';\n\n// unicorn.txt => unicorn rainbow\nconst stream = fs.createReadStream('unicorn.txt')\n\t.pipe(new FirstChunkStream({chunkSize: 7}, async (chunk, encoding) => {\n\t\treturn uint8ArrayToString(chunk).toUpperCase();\n\t}));\n\nconst data = await getStream(stream);\n\nif (data.length < 7) {\n\tthrow new Error('Couldn\\'t get the minimum required first chunk length');\n}\n\nconsole.log(data);\n//=> 'UNICORN rainbow'\n```\n\n## API\n\n### FirstChunkStream(options, transform)\n\n`FirstChunkStream` constructor.\n\n#### transform(chunk, encoding)\n\nType: `Function`\n\nAsync function that receives the required `options.chunkSize` bytes.\n\nExpected to return an buffer-like object or `string` or object of form {buffer: `Uint8Array`, encoding: `string`} to send to stream or `firstChunkStream.stop` to end stream right away.\n\nAn error thrown from this function will be emitted as stream errors.\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 `options.chunkSize` value. You should check for this yourself if you strictly depend on the length.\n\n```js\nimport FirstChunkStream from 'first-chunk-stream';\n\nnew FirstChunkStream({chunkSize: 7}, async (chunk, encoding) => {\n\treturn chunk.toString(encoding).toUpperCase(); // Send string to stream\n});\n\nnew FirstChunkStream({chunkSize: 7}, async (chunk, encoding) => {\n\treturn chunk; // Send buffer to stream\n});\n\nnew FirstChunkStream({chunkSize: 7}, async (chunk, encoding) => {\n\treturn {\n\t\tbuffer: chunk,\n\t\tencoding: encoding,\n\t}; // Send buffer with encoding to stream\n});\n\nnew FirstChunkStream({chunkSize: 7}, async (chunk, encoding) => {\n\treturn FirstChunkStream.stop; // End the stream early\n});\n\nnew FirstChunkStream({chunkSize: 7}, async (chunk, encoding) => {\n\tthrow new Error('Unconditional error'); // Emit stream error\n});\n```\n\n#### options\n\nType: `object`\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###### chunkSize\n\nType: `number`\n\nThe number of bytes to buffer.","users":{}}