{"name":"it-concat","version":"1.0.1","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":"bc3d345cb79372a7952a8cc456df3fb90d1a9831","_id":"it-concat@1.0.1","_nodeVersion":"14.9.0","_npmVersion":"6.14.8","dist":{"integrity":"sha512-ca7tnIqSpPycty9K+x08OwFj9kLSrsXgENn7ry2mNXlFlUkgEZe1/xvBjwnUlUEHvnITMj4Mq7ozPm1VaOm8FQ==","shasum":"4ac61c1b0a2185c97e1bd004d45f625902f7d728","tarball":"http://registry-npm.ywwl.com/it-concat/download/it-concat-1.0.1.tgz","fileCount":7,"unpackedSize":8456,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJfUJ+aCRA9TVsSAnZWagAAnNEP/3ajj0lXzth32mz6j/aN\n1SZdyMLgipVSurW01NTyhmtl3ekLLGNAoJFPC4LlMA4jM0sChxsOsr9rRkvc\nm1tLu31BrB+eskfoZaCK4VFOSqjHxgQOQIHB4y5DHvtNnPTMTk82q/Tlvksy\ncPbkRLaoPkcC/bHKHvD5Uno8Px+06QhoYOuIyiCchbyLSTt2yrAG/t0dRwhk\nkUQW4BAriKfWASEBimLvyzinosJnxdtRQ4FrzMpcZw4OUyDVHIncCjAv30ET\negQO01S0jJr6bklMyp7vzkKvCDbdNxir54pIBRBMS9KmvmFZB/ga3/RZkrSN\nlKwkB4Nd3vc2HSLbKlAGyv5FqEjRITU1vg+no4+QYPb6eWcG2yns0te7wVro\nOvBXBenm7mseu19FSyJV53dFlOfEFR00rX3nfbgDoFvkxtWUKDPL3I5Yid0x\nQ0W5biWa2rQxrjzgsKMsQquI/8VjzhMUwjvsOD0cemWlaq/MIEE42T5FEQHt\nDfJSv8HrxkoS3bqRCkNhbEPcg5KXxOq2O1CLJXLJr/ZJEoEcWnIVrsbLsOpI\na3ROpAHivmBrszo47MJlu1uGcKlcwGka7C0/pAWZw8v6u+HrqxBIBdg1gqPv\nViWPWcv4IkAzxnNyKFAhXZAPugWItpx6LRDUrPHuVh/Y+TGvnjdb34jjwEIB\n8Biv\r\n=Lg7x\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIQD+qA/9N6B51bYTrPq/XZwemdYgbZCxHj6zfbcrxZHuoAIgFt239prpY4SFRBXtAm7ziKXyf21duga6Xul3VpreAvI="}],"size":3214,"noattachment":false,"key":"/it-concat/-/it-concat-1.0.1.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.1_1599119257746_0.12983729777035857"},"_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":1599119257871,"_cnpm_publish_time":1599119257871,"dist-tags":{"latest":"3.0.3"}}