{"name":"it-concat","version":"1.0.3","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":"^4.1.0","ava":"^3.12.1","nyc":"^15.1.0","random-bytes":"^1.0.0","random-int":"^2.0.1","standard":"^16.0.3"},"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":"ea52b93f3b66442ef9d4d6a0b6203565086e75d0","_id":"it-concat@1.0.3","_nodeVersion":"15.6.0","_npmVersion":"7.4.0","dist":{"integrity":"sha512-sjeZQ1BWQ9U/W2oI09kZgUyvSWzQahTkOkLIsnEPgyqZFaF9ME5gV6An4nMjlyhXKWQMKEakQU8oRHs2SdmeyA==","shasum":"84db9376e4c77bf7bc1fd933bb90f184e7cef32b","tarball":"http://registry-npm.ywwl.com/it-concat/download/it-concat-1.0.3.tgz","fileCount":7,"unpackedSize":8650,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJgWSGiCRA9TVsSAnZWagAAog0QAJvXLjFvQWV8VqHPw801\npWVT7d3yS/NpCOkHDEynfG1qtaKv6WR151q9ilGwHVYIrKmV8fE4x/d+ISFy\nTtrQ65wrJpZ3fdLdrP/J2EOFNVNVB2Y3flrPcypTsteBCAePyZZhccl4AuYG\nOYwIR5Aw1kb1pP1g1fn4pcqyG5aRHISC3kyfes6rFzV2KvwglhntGpoXKtbZ\nHtYltV6h8iXzHaVlTFDrMWPQ18ayQo50CjT+J+EYQTw2B69LkxyuPIcBlDlQ\nE6P3aCpzF5PbexkLOdohD92Zp1hUFHOC/USE0tWbI05SNVJ8/hZvwUvhRajD\nVVjxEqhssdTCeEsUSnhQow3nU83uwLnCSCD4Jl7nzdpdvsUCLG+w2yw3+Ey3\nTsGtUUqNkT8K5hpOFTlx5mJpVfZ0/a2ey/Ih+Jyd00DCjgZIGGN5f1LfNbt+\nBaz9Xoz4K4bolWvtEEarCcHkH3nYwyTI8zuU8AeeZO9YmdXJegHe6rUQoEiI\ncXvOYUCTn8LCirpqRwbrBGle5MiB5DzoSdOvcu3X7z6g6E1E2AgcStFwnYwp\nJRhywcZ/8k2lQil+msIZEWYClsz83tuHZoHFHM/3R7IzYj8sq23H/0ux7lzS\neY8JF9mRkLZkB3nR4aECwQt6J2psqUz/Auys+QqACVrzjh+fLc3ElrXPHtGv\nzlXF\r\n=KhHR\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIQDjkXfvRcoMC1rWVPUhWM9cVN5tI2ZRc2595Xp7pJ3SOgIgJu98PuK6KGQF6usw2twozJ4H30YNwve51K4pq9Nc+a8="}],"size":3256,"noattachment":false,"key":"/it-concat/-/it-concat-1.0.3.tgz"},"_npmUser":{"name":"alanshaw","email":"alan138@gmail.com"},"directories":{},"maintainers":[{"name":"alanshaw","email":"alan138@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/it-concat_1.0.3_1616454050129_0.8210881977061399"},"_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":1616454050286,"_cnpm_publish_time":1616454050286,"dist-tags":{"latest":"3.0.3"}}