{"name":"it-pipe","version":"1.0.1","description":"Utility to \"pipe\" async iterables together","main":"index.js","scripts":{"test":"nyc --reporter=lcov --reporter=text ava --verbose","lint":"standard"},"author":{"name":"Alan Shaw"},"license":"MIT","devDependencies":{"ava":"^1.4.1","nyc":"^13.3.0","standard":"^12.0.1"},"dependencies":{},"repository":{"type":"git","url":"git+https://github.com/alanshaw/it-pipe.git"},"bugs":{"url":"https://github.com/alanshaw/it-pipe/issues"},"homepage":"https://github.com/alanshaw/it-pipe#readme","keywords":["pipe","pipeline","iterable","iterator","async","await","stream","pump","pull"],"gitHead":"cc3f3d71cda892f25a1ba9e8addc2602d4925a27","_id":"it-pipe@1.0.1","_nodeVersion":"11.14.0","_npmVersion":"6.7.0","_npmUser":{"name":"alanshaw","email":"alan138@gmail.com"},"dist":{"integrity":"sha512-clx7NMIf4eXe3rp4dKLmT5vMYv/hvZv4lNi1/xx4ZJ8CFmpGod9rTKisyBNBTurbCEa3a7503COankdBj/uUCA==","shasum":"6443f12e2a24dd71728c172eb58a159bb957095e","tarball":"http://registry-npm.ywwl.com/it-pipe/download/it-pipe-1.0.1.tgz","fileCount":6,"unpackedSize":7184,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJcvyihCRA9TVsSAnZWagAA4KQP/1Bnq42OH6ngi1OO1GpH\nN2WUvrQ0IEBVukabyUWliS6qfjuYfnv4P3GVTrQ4DGW+/E7NB+ZJegB1UeXZ\nDBYVDJrV3EY5bm02M9ChN2oCseIAsoHmTyFtdWUvESUcxPI3Nfqf+LyYXYcu\nwQBh0zbHIGrdqKtL3I8XiZMAmzHhOf20Qwfz/w3C/JsV9fs2yHtBRQTZggI5\nEPJop1hPE9xCwrur6v6XgzCsPHKGgF4Om1AwJUWO3kIuePbaYxjAnaFrTMcG\nqmEeFJSvCoYqNDgpTdgqBmeyVB4vQUhs5TD9SXhg7Jw0eS9y8YZE2XIqfSSk\nF83+qMAPVv4CA12WWtJJGT5z8M68oaspvPbihT+2dYxCmW+qCm6x6fD/Yz1E\nFQbKMVcUfLU7DBZa2A3XZwQmzyQgOu8VZLT33cQ5MnWwp/5pHn5LOtB2YW6V\n1EDL2KKYOoCL872KSsvfwgg+x1XrqoD3W+9kYojC0q/whru8AxuiiESItjVR\npSbAc0FI6jfsIsIQruC6uYWgx2B8vUNrGQj9FwNtI1oOwwCllybVj8j+cEnS\nieKpSrehoVT7F4MezDHDVQQBRr/c6nRROV6LKVgGVFADwqbjXpLTdFZcYeRs\ndufVSI0WliRwaWe0dSoFVNQ5O9IQLCMf7pX8ZPeqqv8aawDuvdOGRFhe8Q+5\n2u6W\r\n=y+ea\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCIAId1p/Ypdtt7jqGlXnc+VE7PtCW/bpsWShNDIhvKixbAiATvz/pBgfPmTYFxgcf5RzBsVJfK1QRuSRJHnX9pybCBQ=="}],"size":2980,"noattachment":false,"key":"/it-pipe/-/it-pipe-1.0.1.tgz"},"maintainers":[{"name":"alanshaw","email":"alan138@gmail.com"}],"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/it-pipe_1.0.1_1556031649216_0.44277907678958006"},"_hasShrinkwrap":false,"readme":"# it-pipe <!-- omit in toc -->\n\n[![codecov](https://img.shields.io/codecov/c/github/alanshaw/it-pipe.svg?style=flat-square)](https://codecov.io/gh/alanshaw/it-pipe)\n[![CI](https://img.shields.io/github/actions/workflow/status/alanshaw/it-pipe/js-test-and-release.yml?branch=master\\&style=flat-square)](https://github.com/alanshaw/it-pipe/actions/workflows/js-test-and-release.yml?query=branch%3Amaster)\n\n> Utility to \"pipe\" async iterables together\n\n## Table of contents <!-- omit in toc -->\n\n- [Install](#install)\n  - [Browser `<script>` tag](#browser-script-tag)\n- [Usage](#usage)\n- [API](#api)\n  - [`pipe(firstFn, ...fns)`](#pipefirstfn-fns)\n- [API Docs](#api-docs)\n- [License](#license)\n- [Contribution](#contribution)\n\n## Install\n\n```console\n$ npm i it-pipe\n```\n\n### Browser `<script>` tag\n\nLoading this module through a script tag will make it's exports available as `ItPipe` in the global namespace.\n\n```html\n<script src=\"https://unpkg.com/it-pipe/dist/index.min.js\"></script>\n```\n\nBased on this definition of streaming iterables <https://gist.github.com/alanshaw/591dc7dd54e4f99338a347ef568d6ee9>.\n\nAlmost identical to the [`pipeline`](https://github.com/bustle/streaming-iterables#pipeline) function from the [`streaming-iterables`](https://www.npmjs.com/package/streaming-iterables) module except that it supports duplex streams *and* will automatically wrap a \"source\" as the first param in a function.\n\n## Usage\n\n```js\nimport { pipe } from 'it-pipe'\n\nconst result = await pipe(\n  // A source is just an iterable, this is shorthand for () => [1, 2, 3]\n  [1, 2, 3],\n  // A transform takes a source, and returns a source.\n  // This transform doubles each value asynchronously.\n  function transform (source) {\n    return (async function * () { // A generator is async iterable\n      for await (const val of source) yield val * 2\n    })()\n  },\n  // A sink, it takes a source and consumes it, optionally returning a value.\n  // This sink buffers up all the values from the source and returns them.\n  async function collect (source) {\n    const vals = []\n    for await (const val of source) {\n      vals.push(val)\n    }\n    return vals\n  }\n)\n\nconsole.log(result) // 2,4,6\n```\n\n## API\n\n### `pipe(firstFn, ...fns)`\n\nCalls `firstFn` and then every function in `fns` with the result of the previous function. The final return is the result of the last function in `fns`.\n\nNote:\n\n- `firstFn` may be a `Function` or an `Iterable`\n- `firstFn` or any of `fns` may be a [duplex object](https://gist.github.com/alanshaw/591dc7dd54e4f99338a347ef568d6ee9#duplex-it) (an object with a `sink` and `source`).\n\n## API Docs\n\n- <https://alanshaw.github.io/it-pipe>\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":1556031649375,"_cnpm_publish_time":1556031649375,"dist-tags":{"latest":"3.0.1"}}