{"name":"it-concat","version":"2.0.0","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":"^5.0.0"},"devDependencies":{"@types/bl":"^5.0.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":"1f6c4d1f0c64538cf0035772d25f9277ae9e7d0a","_id":"it-concat@2.0.0","_nodeVersion":"15.12.0","_npmVersion":"7.6.3","dist":{"integrity":"sha512-jchrEB3fHlUENWkVJRmbFJ1A7gcjJDmwiolQsHhVC14DpUIbX8fgr3SOC7XNE5OoUUQNL6/RaMCPChkPemyQUw==","shasum":"b4dc02aeb7365bada05b247c1ee50f3bbc147419","tarball":"http://registry-npm.ywwl.com/it-concat/download/it-concat-2.0.0.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\nwsFcBAEBCAAQBQJgeVvjCRA9TVsSAnZWagAADuQP/jZ0ms832Lbg0Oy/FzZV\nCp8W93/nLONiVJysho0qArNEFkeh3k4vyKER5gezq4c5VkhFPcssSRA/esdF\nTVovEqdsQP1QCI2tb329CNR1asRGHOe/t9vBJaJIzw9FzZU6AZ2wPat2EyeY\nja6C9E6ZbH22WNl0XiFezp/PQCvHQXr1azoPt3+sXHHyuSTBJ8YkSzFNWZyU\nIKXMT6SsJWEJ1mFAQRKV27RBgdnYDKCVl20HXVtfQ2W6SAy+OfdY5IR2icMq\nnSMv+YZdDS61Xa0v4ZFaeL3gCX21T25MMQajBxm2OFdifAYMX585ByvIZYwJ\nj2iw98fKaHy/JiGpfyAJ7pJNCp0S+Kx/QSUWyHnUCwbMEJGwmaaP60Kd3ElX\nJUyLp9BoJDH07i+qkK2Ht9pdgtUcUtu2lJ660GPAeI6fcBZByveIL/5gc/Xu\n0bDyb/cAfba8PLNidj41jHcFvIqzCyVHAc47CMe4X/07qFhI+ThsYJfkpZJb\nS3TZsXW9Cp+mnXjoIDQ0X12YEU8iWbitAI/5ixmhmc6ZACnWVDe14yQmUsmC\nzJ9zCSbX74Xw6TqkGkuA7Na/5dOUrFqXGVF8ReeQT7aOR7EaHTO1DN49/zut\nhY/8dXob3koVG8EYpezyTnI/hqNpBT5U6ED9w2+bRVJhoPt2KnDYzot2yLll\nb/Q5\r\n=jAJ+\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEYCIQCrT74CHHR1kuElcKol/V31Xhp3RayHLJlXuGNNtF6mQQIhAMLKt3RG8OH6EbeoyRnM2YFkfOdaZT0aGD1+5G3wcbpj"}],"size":3255,"noattachment":false,"key":"/it-concat/-/it-concat-2.0.0.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_2.0.0_1618566114758_0.5693505028024441"},"_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":1618566114887,"_cnpm_publish_time":1618566114887,"dist-tags":{"latest":"3.0.3"}}