{"name":"it-pipe","version":"1.0.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"},"gitHead":"7ea1cabc341e9b758475822df449b7295f2a994d","_id":"it-pipe@1.0.0","_nodeVersion":"11.11.0","_npmVersion":"6.7.0","_npmUser":{"name":"alanshaw","email":"alan138@gmail.com"},"dist":{"integrity":"sha512-+C/77wgBNB2YCy0h2iw0RiShLVPxUkBCdGA/ApLFncJX+cZk2eDjQ93RY8D1L3SabZiR7WnlCKLcqBMFUHieDw==","shasum":"1bf44d53cb4d25f15039933241f0d199ed586c16","tarball":"http://registry-npm.ywwl.com/it-pipe/download/it-pipe-1.0.0.tgz","fileCount":5,"unpackedSize":6746,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJco14aCRA9TVsSAnZWagAA/5wP/2OiJol0iQh54tkl+mYh\nZezjadfu3JJ4qnf1kN9x5qavtGjFStIVnM3cfig014R+Ls8yW7ZOgfVG1rJ2\nL8ihE3V0BLim57d1U6hD7CcVzl6OjTGcRWaQ3O3czmhF1vP8LcpABfbtzza3\nn0+6K0OnGVVRxQOiixObTEQbPk0oTfzRAgICw7gOU/fS9rMwiODFtIrSACfl\naydpeF4ileZcdLQundH1X6apeY0Si4G70/ZCGTH0cqRBbOevsUlC8O9xi7L3\nFWeWJQFqeEFLAeu1KzDClaqNdQCtLWaiIA7DaOSGZVwyAXlNuO5I2Z/jEEra\nitl20pl/wpQe4mhVeIZ2VVcADQaaMFkXCGw51ieVfg2OWBqQ0wGU00DiQUwy\nt2u3QfgalnzV3guL6scbau5jcOA2h9IM1Ic4iLXN03iu85hgoZ620Y2Nx8Fw\nQ0LB0zIcXRYXzq1cnuh09V7RFfsS+Nl9YJD1wNCeQTADP1drir7cO7ka/r0b\nqEn1MViaEEGelllySFvBRw7gaPFDo59s4DoeKIO4HB26NgwWJLL6EsnI0mRW\nJnzqr+LxucwDEACQKk2+4qsx4Pp+ZIkG6QioTxYmRe13831QNcJ+6RE6HZfL\n4F/d/TxrtEBGjDe7EDsScutGKR0e/5GH5aYkG73OTaO4glX/a7JvlNnO58G4\n9RGC\r\n=TOJb\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCID4TPBc+EitKOAzkogQUZQem6FPjAmu1wKljY91w+6irAiEAzR+Vzqci1kuHj65hRZU9lVyV0R+FqAhnYA0mBFdKjIo="}],"size":2814,"noattachment":false,"key":"/it-pipe/-/it-pipe-1.0.0.tgz"},"maintainers":[{"name":"alanshaw","email":"alan138@gmail.com"}],"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/it-pipe_1.0.0_1554210329229_0.17327099832091575"},"_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":1554210329323,"_cnpm_publish_time":1554210329323,"dist-tags":{"latest":"3.0.1"}}