{"name":"it-concat","version":"1.0.2","description":"Concat all buffers/strings yielded from an async iterable into a single BufferList/string","main":"index.js","scripts":{"test":"ava test.mjs --verbose","lint":"standard","coverage":"nyc --reporter=text --reporter=lcov npm test"},"keywords":["concat","join","glue","buffer","bufferlist","string","iterable","iterator","async"],"author":{"name":"Alan Shaw"},"license":"MIT","dependencies":{"bl":"^4.0.0"},"devDependencies":{"@types/bl":"^2.1.0","ava":"^3.12.1","nyc":"^15.1.0","random-bytes":"^1.0.0","random-int":"^2.0.1","standard":"^14.3.1"},"repository":{"type":"git","url":"git+https://github.com/alanshaw/it-concat.git"},"bugs":{"url":"https://github.com/alanshaw/it-concat/issues"},"homepage":"https://github.com/alanshaw/it-concat#readme","gitHead":"4855458f216d7546d277ca33ad2696380f733d79","_id":"it-concat@1.0.2","_nodeVersion":"14.13.1","_npmVersion":"6.14.8","dist":{"integrity":"sha512-YZtXOe10qBcTDOsz59AscfmsKRoVPYX5AFxCans2L/QL20Jah1H1/+wzWDaJj8zu0KiA9gys3vBoZIZwhsUeeg==","shasum":"7229fedb935bcf7b2fcac23e040e7588b34143e6","tarball":"http://registry-npm.ywwl.com/it-concat/download/it-concat-1.0.2.tgz","fileCount":7,"unpackedSize":8450,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJfhC8CCRA9TVsSAnZWagAASNwP/0c5O7jL1W+kDpykvsA8\ncLLyRDQWNIxFBCUMV8/Tz44hhfrsIg2/hDCftDY3xAXPdrnj3sA0XLpUzXL7\nDZ8nw2ZoC++oLcvmSciyA2OK5ZJsZ6YIY2hzuAeQYLhu/GCyg9JGzkAzGtzV\nzfVgWY7Na6y+Fz0Q/6RGebjcazEN0iUigjhAMXvWolYkmK762Sm42XlDf3Ai\n11L4pL4eZY514nKFWLoMkkJ76v78jWtv3tgbNyg/GJkGYFq7aGn2aCpO8UXw\nJhrjAVT33uIZHCrqpoIRU+n8PZfQUx0avuosXTcGzOnAxOEaWoLfcJeWcSch\nuecj6z0gbbT56zHtQNcnS4WxvmHRi5uJvxgKmLzJjEAF1kR5DzNCnMnWXNht\n3Y+5P8FPf6aJ4agqtrY+8lIs0J9EPUpnACaj3EYX1FnHKnc6sUyCo5XnQrTx\nF8dOq1tqRmtbNFEs6oeoiZIAcn47IdpFL3ZrJ1qXSdU1afHFuc7EV3WC7zai\nXH37b3jFhH9QY1TP03ldX29nDK1E6/QfArEg4ibR+T7w6aqwy5rDwMrXvA+l\nOdTgOiveOXGJRicKtgHG+Hn469Y3kKdDWqC0boNKTi7BxvSNrin8b6B54jTg\ntSbnxQdpAmafqLbNXi+GBAP3twT3npgF4ni6AXeCyWE/7GIgv+K4f0vNk6rx\n5Mxv\r\n=lGyk\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCIAPspE8v4ELTK/n3qPP02bQ51gV8X13zU+Gp/lEdkZhqAiA/uyppScj+OfZ4l8cC4G34A++CxOoMNiwEdqUIoSMK2w=="}],"size":3211,"noattachment":false,"key":"/it-concat/-/it-concat-1.0.2.tgz"},"maintainers":[{"name":"alanshaw","email":"alan138@gmail.com"}],"_npmUser":{"name":"alanshaw","email":"alan138@gmail.com"},"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/it-concat_1.0.2_1602498305873_0.48905413284066745"},"_hasShrinkwrap":false,"readme":"# it-concat\n\n[![codecov](https://img.shields.io/codecov/c/github/alanshaw/it-concat.svg?style=flat-square)](https://codecov.io/gh/alanshaw/it-concat)\n[![CI](https://img.shields.io/github/actions/workflow/status/alanshaw/it-concat/js-test-and-release.yml?branch=master\\&style=flat-square)](https://github.com/alanshaw/it-concat/actions/workflows/js-test-and-release.yml?query=branch%3Amaster)\n\n> Concat all buffers/strings yielded from an async iterable into a single BufferList/string\n\n# Install\n\n```console\n$ npm i it-concat\n```\n\n## Browser `<script>` tag\n\nLoading this module through a script tag will make it's exports available as `ItConcat` in the global namespace.\n\n```html\n<script src=\"https://unpkg.com/it-concat/dist/index.min.js\"></script>\n```\n\n## Usage\n\nConcat Uint8Arrays to a single [`Uint8ArrayList`](https://www.npmjs.com/package/uint8arraylist):\n\n```js\nimport concat from 'it-concat'\nimport { toString } from 'uint8arrays'\nimport fs from 'fs'\n\nfs.writeFileSync('./test.txt', 'Hello World!')\n\n// Node.js Readable Streams are async iterables!\nconst chunks = await concat(fs.createReadStream('./test.txt'))\n\n// chunks is a Uint8ArrayList\nconsole.log(chunks)\n/*\nUint8ArrayList {\n  _bufs: [ <Uint8Array 48 65 6c 6c 6f 20 57 6f 72 6c 64 21> ],\n  length: 12\n}\n*/\nconsole.log(toString(chunks.subarray)))\n// Hello World!\n```\n\nConcat Uint8Arrays to a single *string*:\n\n```js\nimport concat from 'it-concat'\nimport fs from 'fs'\n\nfs.writeFileSync('./test.txt', 'Hello World!')\n\n// Node.js Readable Streams are async iterables!\n// Note that we pass `{ type: 'string' }` to tell concat that we want a string\n// back and not a Uint8Array. This is necessary because the source data is Uint8Array(s).\nconst chunks = await concat(fs.createReadStream('./test.txt'), { type: 'string' })\n\nconsole.log(chunks)\n// Hello World!\n```\n\nConcat strings to a single string:\n\n```js\nimport concat from 'it-concat'\nimport fs from 'fs'\n\nfs.writeFileSync('./test.txt', 'Hello World!')\n\n// Node.js Readable Streams are async iterables!\n// Note that we don't need to pass `{ type: 'string' }` to tell concat that we\n// want a string back because the source data is Uint8Array(s).\nconst chunks = await concat(fs.createReadStream('./test.txt', { encoding: 'utf8' }))\n\nconsole.log(chunks)\n// Hello World!\n```\n\n## API\n\n```js\nimport concat from 'it-concat'\n```\n\n### `concat(source, options?): Promise`\n\nConcat all Uint8Arrays or strings yielded from the async iterable `source` into a single [`Uint8ArrayList`](https://www.npmjs.com/package/bl) or `string`.\n\n- `source` (`AsyncIterable<Uint8Array | Uint8ArrayList | string>`) - the source iterable to concat from\n- `options` (`Object`) - optional options\n- `options.type` (`string`) - return type of the function, pass `'string'` to recieve a string or `'Uint8Array'` for a `Uint8ArrayList`.\n\nReturns a `Promise` that resolves to a `Uint8ArrayList` or `string`.\n\nIf `options.type` is *not* passed the type of the objects yielded from the `source` is detected and a `Uint8ArrayList` or `string` is returned appropriately. If the `source` does not yield anything an empty `Uint8ArrayList` is returned. If the source is expected to return strings (but may not yield anything), pass `options.type: 'string'` to ensure an empty string is returned instead of an empty `Uint8ArrayList`.\n\n## Related\n\n- [`stream-to-it`](https://www.npmjs.com/package/stream-to-it) Convert Node.js streams to streaming iterables\n- [`it-pipe`](https://www.npmjs.com/package/it-pipe) Utility to \"pipe\" async iterables together\n\n[List of awesome modules for working with async iterables](https://github.com/alanshaw/it-awesome).\n\n# License\n\nLicensed under either of\n\n- Apache 2.0, ([LICENSE-APACHE](LICENSE-APACHE) / <http://www.apache.org/licenses/LICENSE-2.0>)\n- MIT ([LICENSE-MIT](LICENSE-MIT) / <http://opensource.org/licenses/MIT>)\n\n# Contribution\n\nUnless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.\n","publish_time":1602498305971,"_cnpm_publish_time":1602498305971,"dist-tags":{"latest":"3.0.3"}}