{"name":"it-pipe","version":"1.1.0","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":"825195720c72bf40c08335223bfa40ae2624d150","_id":"it-pipe@1.1.0","_nodeVersion":"12.11.0","_npmVersion":"6.11.3","_npmUser":{"name":"alanshaw","email":"alan138@gmail.com"},"dist":{"integrity":"sha512-lF0/3qTVeth13TOnHVs0BTFaziwQF7m5Gg+E6JV0BXcLKutC92YjSi7bASgkPOXaLEb+YvNZrPorGMBIJvZfxg==","shasum":"f5964c6bb785dd776f11a62d1e75964787ab95ce","tarball":"http://registry-npm.ywwl.com/it-pipe/download/it-pipe-1.1.0.tgz","fileCount":8,"unpackedSize":9182,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJdtgDxCRA9TVsSAnZWagAAWzoP/0Do0wpUGSYnoE81vpgv\nyap6zsJKy2ZNdyCNrnz6z2+ZyCq5Tdcv1n4tyu6G1Sp6OTwjxhnwIKmpNglP\nY99kNtw+S7sp/0Sol718Iti0LL4nUNQ2Evvap9qryiyFlu4H9biJAI7aBy9P\no2xhW8pwx15shxNUD3OFG8h4gA5KPnKuFgFE82JrkM+FcMxQmMEpJb4dJOJS\n3HqCXRMKGOShBseHQmRklVT2Nih17Ewr9JunIMnzTVisHp0+hEogklcdZ6Lm\ndsCWwBplEGbpwkxfm42UQJadqN188RQn4opplW3TXOfeX2gxR6B6UVMC4pU5\nWXCfUQbszGqvuhpn4Ym7+LX4qmhkcIVqnu1TwpicY1Bm0XaDUiX+ZbRU/AM4\ncRxpYuycktHv0+pb/teY+Ehd8CgAgLVqGXsihJdl4IS0XS05Xb28tOTIs8f8\ni+CqzJkZk8zZeUeDJGEAsCSI7rtr9d/VVMOgsyxBscou72uE0UiVfw0bEUua\nFTggdpDI2uUXIbbtBrDVtxrnDz+TPTOaOCvwRcf0Zaswr6/+7bL175xURNpT\n8bvxvKo0SVo6ME+UJ/ZMWuENh5lYOfOxKKh60T7Lp5E4475KlH3DSqpCCL9Y\nbvQpKTcS4urb1olzbJ2piahSpIwRMFMj8nKwhBY5XH9TPYW7zCl3BeM6amwf\nRkdS\r\n=sS6U\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIQDiiYtpSwyxvmdvoIa+D1ejU+J+xnHvum2bx269LIUjpAIgK7bHONPHD1WhQULqRtuHDHlXOlIek05r2USrpy8PJTM="}],"size":3310,"noattachment":false,"key":"/it-pipe/-/it-pipe-1.1.0.tgz"},"maintainers":[{"name":"alanshaw","email":"alan138@gmail.com"}],"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/it-pipe_1.1.0_1572208881299_0.9791830351424584"},"_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":1572208881475,"_cnpm_publish_time":1572208881475,"dist-tags":{"latest":"3.0.1"}}