{"name":"it-to-stream","version":"1.0.0","description":"Convert streaming iterables to Node.js streams","main":"src/index.js","browser":{"stream":"readable-stream"},"scripts":{"test":"ava test/*.test.js --verbose","lint":"standard","coverage":"nyc --reporter=text --reporter=lcov npm test"},"keywords":["stream","readablestream"],"author":{"name":"Alan Shaw"},"license":"MIT","dependencies":{"buffer":"^6.0.3","fast-fifo":"^1.0.0","get-iterator":"^1.0.2","p-defer":"^3.0.0","p-fifo":"^1.0.0","readable-stream":"^3.6.0"},"devDependencies":{"ava":"^3.9.0","it-pair":"^1.0.0","nyc":"^15.1.0","standard":"^16.0.3"},"directories":{"test":"test"},"repository":{"type":"git","url":"git+https://github.com/alanshaw/it-to-stream.git"},"bugs":{"url":"https://github.com/alanshaw/it-to-stream/issues"},"homepage":"https://github.com/alanshaw/it-to-stream#readme","gitHead":"082f0ad069d35f7f8608e905beffd6ac9176806c","_id":"it-to-stream@1.0.0","_nodeVersion":"15.12.0","_npmVersion":"7.6.3","dist":{"integrity":"sha512-pLULMZMAB/+vbdvbZtebC0nWBTbG581lk6w8P7DfIIIKUfa8FbY7Oi0FxZcFPbxvISs7A9E+cMpLDBc1XhpAOA==","shasum":"6c47f91d5b5df28bda9334c52782ef8e97fe3a4a","tarball":"http://registry-npm.ywwl.com/it-to-stream/download/it-to-stream-1.0.0.tgz","fileCount":13,"unpackedSize":16894,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJgbrr9CRA9TVsSAnZWagAAeq4P/17lDEeStkBRffropJZv\nT0Sb4oZrjRJc1yH/uCj3u4m/pLbLcTlsmSUn/XCGrJrkMaTPMJtOstDAbsqj\ndebXZmXTkg3TGvaxhZTbKb3UCJdcbQ3YDM0oB/eaPCvaVn78Xz1QxyxgWpNH\ntjSZV1mxyACqEbTM5dU8MbqjGdmYkQrCKtCtFy1PKQHJPT6F02mylGSaKAmL\nq3/6j3yysZk6wamjtwqZBGLqbZ/VGqq2FkovtDk9YIIbYuLt2p2CHYprfjDP\nO26YW3FZLo7Y5v2AI2IHCFWi7i8J94T/pjzEAu4DNmneANccOVyq01nyNmH8\ny8VMQ5X9sgc6mfpCBKYH1nWpiLnoS6sDBAEQSDl6TleF5a2h26GQbvdj+6US\nxQitm74sWuhsi8GXBEO/JLGVon07u69FY97adXPqu7qLFZkRUcvYdR198xVf\nBKwU0E8lrf2wDyjtpbM+Yq/SSz4FJJh7zF7wLmP5q3uXcLI+w9rZ3UsgHSKg\nGYFTWif7gZSvjP8R3PILiyWwLSUDwvssOlAI21NxcqyxkGZHbmB/5xkW9FVn\nj2qI3BtL2csLLAQxpYGh+u7xwBubFbWuEVG8F9hkJTqPJKg0zcjG2NuNtzfJ\nZPd0ACJFgeScpnico2rb6o5ojdv8W2vRWM5iEw+mhUpfYB2pvwH5hxgXARYw\n1BJw\r\n=l3dT\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCIEdeac7O93ny+BV8zFYC1IVZn6N47EzJixrPJ271FPdcAiBhl7QJbnW7bO5+jqbtvS761XAaC43fFWnh2gwaugubHg=="}],"size":4827,"noattachment":false,"key":"/it-to-stream/-/it-to-stream-1.0.0.tgz"},"_npmUser":{"name":"alanshaw","email":"alan138@gmail.com"},"maintainers":[{"name":"alanshaw","email":"alan138@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/it-to-stream_1.0.0_1617869564701_0.19280600201734854"},"_hasShrinkwrap":false,"readme":"# it-to-stream\n\n[![Build Status](https://travis-ci.org/alanshaw/it-to-stream.svg?branch=master)](https://travis-ci.org/alanshaw/it-to-stream)\n[![dependencies Status](https://status.david-dm.org/gh/alanshaw/it-to-stream.svg)](https://david-dm.org/alanshaw/it-to-stream)\n[![JavaScript Style Guide](https://img.shields.io/badge/code_style-standard-brightgreen.svg)](https://standardjs.com)\n\n> Convert streaming iterables to Node.js streams\n\n## Install\n\n```sh\nnpm i it-to-stream\n```\n\n## Usage\n\n```js\nconst toStream = require('it-to-stream')\n```\n\n### Convert source iterable to readable stream\n\n```js\n// A streaming iterable \"source\" is just an (async) iterable\nconst source = (async function * () {\n  for (const value of [1, 2, 3, 4]) yield Buffer.from(value.toString())\n})()\n\nconst readable = toStream.readable(source)\n\n// Now we have a readable stream, we can consume it by\nreadable.on('data', console.log)\n// or\nreadable.pipe(writable)\n// or\npipeline(readable, writable, err => console.log(err || 'done'))\n```\n\n### Convert sink iterable to writable stream\n\n```js\n// A streaming iterable \"sink\" is an (async) function that takes a \"source\"\n// and consumes it.\nconst sink = async source => {\n  for await (const chunk of source) {\n    console.log(chunk.toString())\n  }\n}\n\nconst writable = toStream.writable(sink)\n\n// Now we have a writable stream, we can pipe to it\nfs.createReadStream('/path/to/file').pipe(writable)\n```\n\n### Convert transform iterable to transform stream\n\n```js\n// A streaming iterable \"transform\" is a function that takes a \"source\" and\n// returns a \"source\".\nconst transform = source => (async function * () {\n  for await (const chunk of source) {\n    // Replace all space characters with dashes\n    yield Buffer.from(chunk.toString().replace(/ /g, '-'))\n  }\n})()\n\nconst transform = toStream.transform(transform)\n\n// Now we have a transform stream, we can pipe to and from it\nfs.createReadStream('/path/to/file')\n  .pipe(transform)\n  .pipe(fs.createWriteStream('/path/to/file2'))\n```\n\n## API\n\n```js\nconst toStream = require('it-to-stream')\n```\n\n### `toStream.readable(source, [options]): Readable`\n\nConvert a [source](https://gist.github.com/alanshaw/591dc7dd54e4f99338a347ef568d6ee9#source-it) iterable to a [`Readable`](https://nodejs.org/dist/latest/docs/api/stream.html#stream_readable_streams) stream.\n\n`options` are passed directly to the `Readable` constructor.\n\n### `toStream.writable(sink, [options]): Writable`\n\nConvert a [sink](https://gist.github.com/alanshaw/591dc7dd54e4f99338a347ef568d6ee9#sink-it) iterable to a [`Writable`](https://nodejs.org/dist/latest/docs/api/stream.html#stream_writable_streams) stream.\n\n`options` are passed directly to the `Writable` constructor.\n\n### `toStream.transform(transform, [options]): Transform`\n\nConvert a [transform](https://gist.github.com/alanshaw/591dc7dd54e4f99338a347ef568d6ee9#transform-it) iterable to a [`Transform`](https://nodejs.org/dist/latest/docs/api/stream.html#stream_duplex_and_transform_streams) stream.\n\n`options` are passed directly to the `Transform` constructor.\n\n### `toStream.duplex(duplex, [options]): Duplex`\n\nConvert a [duplex](https://gist.github.com/alanshaw/591dc7dd54e4f99338a347ef568d6ee9#duplex-it) iterable to a [`Duplex`](https://nodejs.org/dist/latest/docs/api/stream.html#stream_duplex_and_transform_streams) stream.\n\n`options` are passed directly to the `Duplex` constructor.\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## Contribute\n\nFeel free to dive in! [Open an issue](https://github.com/alanshaw/it-to-stream/issues/new) or submit PRs.\n\n## License\n\n[MIT](LICENSE) © Alan Shaw\n","publish_time":1617869564872,"_cnpm_publish_time":1617869564872,"dist-tags":{"latest":"1.0.0"}}