{"_id":"async-iterator-to-stream","_rev":"4635326","name":"async-iterator-to-stream","description":"Convert an async iterator/iterable to a readable stream","dist-tags":{"latest":"1.2.0"},"maintainers":[{"name":"julien-f","email":"julien.fontanet@isonoe.net"},{"name":"marsaud","email":"marsaud.fabrice@neuf.fr"},{"name":"pdonias","email":"pierre.donias@gmail.com"}],"time":{"modified":"2026-04-10T19:14:40.000Z","created":"2018-03-26T14:15:57.448Z","1.2.0":"2020-04-10T07:49:10.455Z","1.1.0":"2018-11-27T09:53:28.730Z","1.0.3":"2018-07-09T12:08:28.473Z","1.0.2":"2018-04-18T19:02:14.792Z","1.0.1":"2018-03-26T14:21:05.566Z","1.0.0":"2018-03-26T14:15:57.448Z"},"users":{},"repository":{"type":"git","url":"git+https://github.com/JsCommunity/async-iterator-to-stream.git"},"versions":{"1.2.0":{"name":"async-iterator-to-stream","version":"1.2.0","license":"ISC","description":"Convert an async iterator/iterable to a readable stream","keywords":["async","generator","iterable","iteration","iterator","promise","readable","stream"],"homepage":"https://github.com/JsCommunity/async-iterator-to-stream","bugs":{"url":"https://github.com/JsCommunity/async-iterator-to-stream/issues"},"repository":{"type":"git","url":"git+https://github.com/JsCommunity/async-iterator-to-stream.git"},"preferGlobal":false,"main":"dist/","engines":{"node":">=6"},"dependencies":{"readable-stream":"^3.0.5"},"devDependencies":{"@babel/cli":"^7.1.2","@babel/core":"^7.1.2","@babel/preset-env":"^7.1.0","babel-eslint":"^10.0.1","babel-jest":"^24.9.0","cross-env":"^6.0.2","eslint":"^6.5.1","eslint-config-prettier":"^6.3.0","eslint-config-standard":"^14.1.0","eslint-plugin-import":"^2.14.0","eslint-plugin-node":"^10.0.0","eslint-plugin-promise":"^4.0.1","eslint-plugin-standard":"^4.0.0","husky":"^3.0.8","jest":"^24.9.0","lint-staged":"^9.4.1","prettier":"^1.15.2","rimraf":"^3.0.0"},"scripts":{"build":"cross-env NODE_ENV=production babel --source-maps --out-dir=dist/ src/","clean":"rimraf dist/","dev":"cross-env NODE_ENV=development babel --watch --source-maps --out-dir=dist/ src/","dev-test":"jest --bail --watch","prebuild":"npm run clean","predev":"npm run prebuild","prepublishOnly":"npm run build","pretest":"eslint --ignore-path .gitignore .","test":"jest"},"husky":{"hooks":{"pre-commit":"lint-staged"}},"lint-staged":{"*.js":["prettier --write","git add","eslint --ignore-pattern '!*'","jest --findRelatedTests --passWithNoTests"]},"gitHead":"092650289f451023a8456ca5e9bc5ceb9a6c226f","_id":"async-iterator-to-stream@1.2.0","_nodeVersion":"12.16.1","_npmVersion":"6.14.4","dist":{"shasum":"fd90483e3a308be2b5a1cf2d28d6f62f4f7923e0","size":5838,"noattachment":false,"key":"/async-iterator-to-stream/-/async-iterator-to-stream-1.2.0.tgz","tarball":"http://registry.cnpm.dingdandao.com/async-iterator-to-stream/download/async-iterator-to-stream-1.2.0.tgz"},"maintainers":[{"name":"julien-f","email":"julien.fontanet@isonoe.net"},{"name":"marsaud","email":"marsaud.fabrice@neuf.fr"},{"name":"pdonias","email":"pierre.donias@gmail.com"}],"_npmUser":{"name":"julien-f","email":"julien.fontanet@isonoe.net"},"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/async-iterator-to-stream_1.2.0_1586504950185_0.07547558949191546"},"_hasShrinkwrap":false,"publish_time":1586504950455,"_cnpm_publish_time":1586504950455,"_cnpmcore_publish_time":"2021-12-16T14:38:50.397Z"},"1.1.0":{"name":"async-iterator-to-stream","version":"1.1.0","license":"ISC","description":"Convert an async iterator/iterable to a readable stream","keywords":["async","generator","iterable","iteration","iterator","promise","readable","stream"],"homepage":"https://github.com/JsCommunity/async-iterator-to-stream","bugs":{"url":"https://github.com/JsCommunity/async-iterator-to-stream/issues"},"repository":{"type":"git","url":"git+https://github.com/JsCommunity/async-iterator-to-stream.git"},"preferGlobal":false,"main":"dist/","bin":{},"engines":{"node":">=6"},"dependencies":{"readable-stream":"^3.0.5"},"devDependencies":{"@babel/cli":"^7.1.2","@babel/core":"^7.1.2","@babel/preset-env":"^7.1.0","babel-core":"^7.0.0-bridge.0","babel-eslint":"^10.0.1","babel-jest":"^23.2.0","babel-plugin-lodash":"^3.3.2","cross-env":"^5.1.4","eslint":"^5.9.0","eslint-config-prettier":"^3.3.0","eslint-config-standard":"^12.0.0","eslint-plugin-import":"^2.14.0","eslint-plugin-node":"^7.0.1","eslint-plugin-promise":"^4.0.1","eslint-plugin-standard":"^4.0.0","husky":"^1.1.0","jest":"^23.3.0","prettier":"^1.15.2","rimraf":"^2.6.2"},"scripts":{"build":"cross-env NODE_ENV=production babel --source-maps --out-dir=dist/ src/","clean":"rimraf dist/","dev":"cross-env NODE_ENV=development babel --watch --source-maps --out-dir=dist/ src/","dev-test":"jest --bail --watch","prebuild":"npm run clean","predev":"npm run prebuild","prepublishOnly":"npm run build","pretest":"eslint --ignore-path .gitignore .","test":"jest"},"husky":{"hooks":{"commit-msg":"npm test"}},"jest":{"collectCoverage":true,"testEnvironment":"node","roots":["<rootDir>/src"],"testRegex":"\\.spec\\.js$"},"gitHead":"0fb2ec6236283da6668bad52f04905338b5e6957","_id":"async-iterator-to-stream@1.1.0","_npmVersion":"6.4.1","_nodeVersion":"8.12.0","_npmUser":{"name":"julien-f","email":"julien.fontanet@isonoe.net"},"dist":{"shasum":"02ce9031de5efb36b2a5e82a0e280318cfd1a6eb","size":5212,"noattachment":false,"key":"/async-iterator-to-stream/-/async-iterator-to-stream-1.1.0.tgz","tarball":"http://registry.cnpm.dingdandao.com/async-iterator-to-stream/download/async-iterator-to-stream-1.1.0.tgz"},"maintainers":[{"name":"julien-f","email":"julien.fontanet@isonoe.net"},{"name":"marsaud","email":"marsaud.fabrice@neuf.fr"},{"name":"pdonias","email":"pierre.donias@gmail.com"}],"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/async-iterator-to-stream_1.1.0_1543312408601_0.00775955302396758"},"_hasShrinkwrap":false,"publish_time":1543312408730,"_cnpm_publish_time":1543312408730,"_cnpmcore_publish_time":"2021-12-16T14:38:50.634Z"},"1.0.3":{"name":"async-iterator-to-stream","version":"1.0.3","license":"ISC","description":"Convert an async iterator/iterable to a readable stream","keywords":["async","generator","iterable","iteration","iterator","promise","readable","stream"],"homepage":"https://github.com/JsCommunity/async-iterator-to-stream","bugs":{"url":"https://github.com/JsCommunity/async-iterator-to-stream/issues"},"repository":{"type":"git","url":"git+https://github.com/JsCommunity/async-iterator-to-stream.git"},"preferGlobal":false,"main":"dist/","bin":{},"files":["dist/"],"engines":{"node":">=6"},"dependencies":{"readable-stream":"^2.3.5"},"devDependencies":{"@babel/cli":"7.0.0-beta.52","@babel/core":"7.0.0-beta.52","@babel/preset-env":"7.0.0-beta.52","babel-core":"^7.0.0-bridge.0","babel-eslint":"^8.2.2","babel-jest":"^23.2.0","babel-plugin-lodash":"^3.3.2","cross-env":"^5.1.4","eslint":"^5.1.0","eslint-config-standard":"^11.0.0","eslint-plugin-import":"^2.9.0","eslint-plugin-node":"^6.0.1","eslint-plugin-promise":"^3.7.0","eslint-plugin-standard":"^3.0.1","husky":"^0.14.3","jest":"^23.3.0","rimraf":"^2.6.2"},"scripts":{"build":"cross-env NODE_ENV=production babel --source-maps --out-dir=dist/ src/","clean":"rimraf dist/","commitmsg":"npm test","dev":"cross-env NODE_ENV=development babel --watch --source-maps --out-dir=dist/ src/","dev-test":"jest --bail --watch","prebuild":"npm run clean","predev":"npm run prebuild","prepublishOnly":"npm run build","pretest":"eslint --ignore-path .gitignore .","test":"jest"},"jest":{"collectCoverage":true,"testEnvironment":"node","roots":["<rootDir>/src"],"testRegex":"\\.spec\\.js$"},"gitHead":"83bcf79bdf9484fe8d5fcc1ed5b866ad06251102","_id":"async-iterator-to-stream@1.0.3","_npmVersion":"5.6.0","_nodeVersion":"8.11.3","_npmUser":{"name":"julien-f","email":"julien.fontanet@isonoe.net"},"dist":{"shasum":"d35865a4ef77927f3b0863d216890999b9954028","size":5155,"noattachment":false,"key":"/async-iterator-to-stream/-/async-iterator-to-stream-1.0.3.tgz","tarball":"http://registry.cnpm.dingdandao.com/async-iterator-to-stream/download/async-iterator-to-stream-1.0.3.tgz"},"maintainers":[{"name":"julien-f","email":"julien.fontanet@isonoe.net"},{"name":"marsaud","email":"marsaud.fabrice@neuf.fr"},{"name":"pdonias","email":"pierre.donias@gmail.com"}],"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/async-iterator-to-stream_1.0.3_1531138108384_0.1694294671678882"},"_hasShrinkwrap":false,"publish_time":1531138108473,"_cnpm_publish_time":1531138108473,"_cnpmcore_publish_time":"2021-12-16T14:38:50.880Z"},"1.0.2":{"name":"async-iterator-to-stream","version":"1.0.2","license":"ISC","description":"Convert an async iterator/iterable to a readable stream","keywords":["async","generator","iterable","iteration","iterator","promise","readable","stream"],"homepage":"https://github.com/JsCommunity/async-iterator-to-stream","bugs":{"url":"https://github.com/JsCommunity/async-iterator-to-stream/issues"},"repository":{"type":"git","url":"git+https://github.com/JsCommunity/async-iterator-to-stream.git"},"preferGlobal":false,"main":"dist/","bin":{},"files":["dist/"],"browserslist":[">2%"],"engines":{"node":">=4"},"dependencies":{"@babel/runtime":"^7.0.0-beta.42","readable-stream":"^2.3.5"},"devDependencies":{"@babel/cli":"^7.0.0-beta.42","@babel/core":"^7.0.0-beta.42","@babel/plugin-transform-runtime":"^7.0.0-beta.42","@babel/preset-env":"^7.0.0-beta.42","@babel/preset-flow":"^7.0.0-beta.42","babel-core":"^7.0.0-bridge.0","babel-eslint":"^8.2.2","babel-jest":"^21","babel-plugin-lodash":"^3.3.2","cross-env":"^5.1.4","eslint":"^4.19.1","eslint-config-standard":"^11.0.0","eslint-plugin-import":"^2.9.0","eslint-plugin-node":"^6.0.1","eslint-plugin-promise":"^3.7.0","eslint-plugin-standard":"^3.0.1","flow-bin":"^0.68.0","husky":"^0.14.3","jest":"^21","rimraf":"^2.6.2"},"scripts":{"build":"cross-env NODE_ENV=production babel --source-maps --out-dir=dist/ src/","clean":"rimraf dist/","commitmsg":"npm test","dev":"cross-env NODE_ENV=development babel --watch --source-maps --out-dir=dist/ src/","dev-test":"jest --bail --watch","posttest":"jest","prebuild":"npm run clean","predev":"npm run prebuild","prepublishOnly":"npm run build","pretest":"eslint --ignore-path .gitignore --fix .","test":"flow status"},"jest":{"collectCoverage":true,"testEnvironment":"node","roots":["<rootDir>/src"],"testRegex":"\\.spec\\.js$"},"gitHead":"31747a73b303168bf79ef83c14630761a2fad4d1","_id":"async-iterator-to-stream@1.0.2","_npmVersion":"5.8.0","_nodeVersion":"9.10.1","_npmUser":{"name":"julien-f","email":"julien.fontanet@isonoe.net"},"dist":{"shasum":"7d3497e441dd2997b7e3ef15f4c367a979692543","size":5741,"noattachment":false,"key":"/async-iterator-to-stream/-/async-iterator-to-stream-1.0.2.tgz","tarball":"http://registry.cnpm.dingdandao.com/async-iterator-to-stream/download/async-iterator-to-stream-1.0.2.tgz"},"maintainers":[{"name":"julien-f","email":"julien.fontanet@isonoe.net"},{"name":"marsaud","email":"marsaud.fabrice@neuf.fr"},{"name":"pdonias","email":"pierre.donias@gmail.com"}],"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/async-iterator-to-stream_1.0.2_1524078134718_0.9223734393633456"},"_hasShrinkwrap":false,"publish_time":1524078134792,"_cnpm_publish_time":1524078134792,"_cnpmcore_publish_time":"2021-12-16T14:38:51.113Z"},"1.0.1":{"name":"async-iterator-to-stream","version":"1.0.1","license":"ISC","description":"Convert an async iterator/iterable to a readable stream","keywords":["async","generator","iterable","iteration","iterator","promise","readable","stream"],"homepage":"https://github.com/JsCommunity/async-iterator-to-stream","bugs":{"url":"https://github.com/JsCommunity/async-iterator-to-stream/issues"},"repository":{"type":"git","url":"git+https://github.com/JsCommunity/async-iterator-to-stream.git"},"preferGlobal":false,"main":"dist/","bin":{},"files":["dist/"],"browserslist":[">2%"],"engines":{"node":">=4"},"dependencies":{"@babel/runtime":"^7.0.0-beta.42","readable-stream":"^2.3.5"},"devDependencies":{"@babel/cli":"^7.0.0-beta.42","@babel/core":"^7.0.0-beta.42","@babel/plugin-transform-runtime":"^7.0.0-beta.42","@babel/preset-env":"^7.0.0-beta.42","@babel/preset-flow":"^7.0.0-beta.42","babel-core":"^7.0.0-bridge.0","babel-eslint":"^8.2.2","babel-jest":"^21","babel-plugin-lodash":"^3.3.2","cross-env":"^5.1.4","eslint":"^4.19.1","eslint-config-standard":"^11.0.0","eslint-plugin-import":"^2.9.0","eslint-plugin-node":"^6.0.1","eslint-plugin-promise":"^3.7.0","eslint-plugin-standard":"^3.0.1","flow-bin":"^0.68.0","husky":"^0.14.3","jest":"^21","rimraf":"^2.6.2"},"scripts":{"build":"cross-env NODE_ENV=production babel --source-maps --out-dir=dist/ src/","clean":"rimraf dist/","commitmsg":"npm test","dev":"cross-env NODE_ENV=development babel --watch --source-maps --out-dir=dist/ src/","dev-test":"jest --bail --watch","posttest":"jest","prebuild":"npm run clean","predev":"npm run prebuild","prepublishOnly":"npm run build","pretest":"eslint --ignore-path .gitignore --fix .","test":"flow status"},"jest":{"collectCoverage":true,"testEnvironment":"node","roots":["<rootDir>/src"],"testRegex":"\\.spec\\.js$"},"gitHead":"65507c7bf4ee91e055c6a8e74d9432756267e056","_id":"async-iterator-to-stream@1.0.1","_npmVersion":"5.6.0","_nodeVersion":"9.9.0","_npmUser":{"name":"julien-f","email":"julien.fontanet@isonoe.net"},"dist":{"shasum":"e609c9102a17412772b9c94ffb77ddffb9b743b2","size":5723,"noattachment":false,"key":"/async-iterator-to-stream/-/async-iterator-to-stream-1.0.1.tgz","tarball":"http://registry.cnpm.dingdandao.com/async-iterator-to-stream/download/async-iterator-to-stream-1.0.1.tgz"},"maintainers":[{"name":"julien-f","email":"julien.fontanet@isonoe.net"},{"name":"marsaud","email":"marsaud.fabrice@neuf.fr"},{"name":"pdonias","email":"pierre.donias@gmail.com"}],"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/async-iterator-to-stream_1.0.1_1522074065521_0.9036091491933695"},"_hasShrinkwrap":false,"publish_time":1522074065566,"_cnpm_publish_time":1522074065566,"_cnpmcore_publish_time":"2021-12-16T14:38:51.386Z"},"1.0.0":{"name":"async-iterator-to-stream","version":"1.0.0","license":"ISC","description":"Convert an async iterator/iterable to a readable stream","keywords":["async","generator","iterable","iteration","iterator","promise","readable","stream"],"homepage":"https://github.com/JsCommunity/async-iterator-to-stream","bugs":{"url":"https://github.com/JsCommunity/async-iterator-to-stream/issues"},"repository":{"type":"git","url":"git+https://github.com/JsCommunity/async-iterator-to-stream.git"},"preferGlobal":false,"main":"dist/","bin":{},"files":["dist/"],"browserslist":[">2%"],"engines":{"node":">=4"},"dependencies":{"@babel/runtime":"^7.0.0-beta.42","readable-stream":"^2.3.5"},"devDependencies":{"@babel/cli":"^7.0.0-beta.42","@babel/core":"^7.0.0-beta.42","@babel/plugin-transform-runtime":"^7.0.0-beta.42","@babel/preset-env":"^7.0.0-beta.42","@babel/preset-flow":"^7.0.0-beta.42","babel-core":"^7.0.0-bridge.0","babel-eslint":"^8.2.2","babel-jest":"^21","babel-plugin-lodash":"^3.3.2","cross-env":"^5.1.4","eslint":"^4.19.1","eslint-config-standard":"^11.0.0","eslint-plugin-import":"^2.9.0","eslint-plugin-node":"^6.0.1","eslint-plugin-promise":"^3.7.0","eslint-plugin-standard":"^3.0.1","flow-bin":"^0.68.0","husky":"^0.14.3","jest":"^21","rimraf":"^2.6.2"},"scripts":{"build":"cross-env NODE_ENV=production babel --source-maps --out-dir=dist/ src/","clean":"rimraf dist/","commitmsg":"npm test","dev":"cross-env NODE_ENV=development babel --watch --source-maps --out-dir=dist/ src/","dev-test":"jest --bail --watch","posttest":"jest","prebuild":"npm run clean","predev":"npm run prebuild","prepublishOnly":"npm run build","pretest":"eslint --ignore-path .gitignore --fix .","test":"flow status"},"jest":{"collectCoverage":true,"testEnvironment":"node","roots":["<rootDir>/src"],"testRegex":"\\.spec\\.js$"},"gitHead":"ab0d2c9a86464c2d61ded8e50cdcefe29199c0ab","_id":"async-iterator-to-stream@1.0.0","_npmVersion":"5.6.0","_nodeVersion":"9.9.0","_npmUser":{"name":"julien-f","email":"julien.fontanet@isonoe.net"},"dist":{"shasum":"c1b328c7cdf2d8965a2c91d584a97100f03a2010","size":5577,"noattachment":false,"key":"/async-iterator-to-stream/-/async-iterator-to-stream-1.0.0.tgz","tarball":"http://registry.cnpm.dingdandao.com/async-iterator-to-stream/download/async-iterator-to-stream-1.0.0.tgz"},"maintainers":[{"name":"julien-f","email":"julien.fontanet@isonoe.net"},{"name":"marsaud","email":"marsaud.fabrice@neuf.fr"},{"name":"pdonias","email":"pierre.donias@gmail.com"}],"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/async-iterator-to-stream_1.0.0_1522073757389_0.7677088601932804"},"_hasShrinkwrap":false,"publish_time":1522073757448,"_cnpm_publish_time":1522073757448,"_cnpmcore_publish_time":"2021-12-16T14:38:51.624Z"}},"readme":"# async-iterator-to-stream\n\n[![Package Version](https://badgen.net/npm/v/async-iterator-to-stream)](https://npmjs.org/package/async-iterator-to-stream) [![Build Status](https://travis-ci.org/JsCommunity/async-iterator-to-stream.png?branch=master)](https://travis-ci.org/JsCommunity/async-iterator-to-stream) [![PackagePhobia](https://badgen.net/packagephobia/install/async-iterator-to-stream)](https://packagephobia.now.sh/result?p=async-iterator-to-stream) [![Latest Commit](https://badgen.net/github/last-commit/JsCommunity/async-iterator-to-stream)](https://github.com/JsCommunity/async-iterator-to-stream/commits/master)\n\n> Convert an async iterator/iterable to a readable stream\n\nEven though this library is dedicated to async iterators, it is fully\ncompatible with synchronous ones.\n\nFurthermore, generators can be used to create readable stream factories!\n\n## Install\n\nInstallation of the [npm package](https://npmjs.org/package/async-iterator-to-stream):\n\n```\n> npm install --save async-iterator-to-stream\n```\n\n## Usage\n\n```js\nconst asyncIteratorToStream = require(\"async-iterator-to-stream\");\n\n// sync/async iterators\nasyncIteratorToStream(new Set([\"foo\", \"bar\"]).values()).pipe(output);\n\n// sync/async iterables\nasyncIteratorToStream.obj([1, 2, 3]).pipe(output);\n\n// if you pass a sync/async generator, it will return a factory instead of a\n// stream\nconst createRangeStream = asyncIteratorToStream.obj(function*(n) {\n  for (let i = 0; i < n; ++i) {\n    yield i;\n  }\n});\ncreateRangeStream(10).pipe(output);\n```\n\n## Example\n\nLet's implement a simpler `fs.createReadStream` to illustrate the usage of this\nlibrary.\n\n```js\nconst asyncIteratorToStream = require(\"async-iterator-to-stream\");\n\n// promisified fs\nconst fs = require(\"mz/fs\");\n\nconst createReadStream = asyncIteratorToStream(async function*(file) {\n  const fd = await fs.open(file, \"r\");\n  try {\n    let size = yield;\n    while (true) {\n      const buf = Buffer.alloc(size);\n      const [n] = await fs.read(fd, buf, 0, size, null);\n      if (n < size) {\n        yield buf.slice(0, n);\n        return;\n      }\n      size = yield buf;\n    }\n  } finally {\n    await fs.close(fd);\n  }\n});\n\ncreateReadStream(\"foo.txt\").pipe(process.stdout);\n```\n\n> If your environment does not support async generators, you may use a sync\n> generator instead and `yield` promises to wait for them.\n\n## Development\n\n```\n# Install dependencies\n> npm\n\n# Run the tests\n> npm test\n\n# Continuously compile\n> npm run dev\n\n# Continuously run the tests\n> npm run dev-test\n\n# Build for production\n> npm run build\n```\n\n## Contributions\n\nContributions are _very_ welcomed, either on the documentation or on\nthe code.\n\nYou may:\n\n- report any [issue](https://github.com/JsCommunity/async-iterator-to-stream/issues)\n  you've encountered;\n- fork and create a pull request.\n\n## License\n\nISC © [Julien Fontanet](https://github.com/julien-f)\n","_attachments":{},"homepage":"https://github.com/JsCommunity/async-iterator-to-stream","bugs":{"url":"https://github.com/JsCommunity/async-iterator-to-stream/issues"},"license":"ISC"}