{"maintainers":[{"name":"anonymous","email":"ben@benlesh.com"}],"keywords":["RxJS","Observable","async-await","AsyncIterable","for-await"],"dist-tags":{"latest":"1.0.0"},"author":{"name":"Ben Lesh","email":"ben@benlesh.com"},"description":"Add async-await for-await loop support to RxJS Observables","readme":"![CI](https://github.com/benlesh/rxjs-for-await/workflows/CI/badge.svg)\n[![npm version](https://badge.fury.io/js/rxjs-for-await.svg)](https://www.npmjs.com/package/rxjs-for-await)\n[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](LICENSE)\n\n# rxjs-for-await\nA library for making RxJS support async-await for-await loops via AsyncIterables\n\n## Four Strategies\n\nThis library exposes 4 different ways to consume an [RxJS](https://rxjs.dev) observable with an async/await `for await..of` loop using `AsyncIterable`. Each of these strategies has pros and cons, so be aware of those as you choose the one that suits your needs.\n\n### eachValueFrom (lossless)\n\n```ts\nasync function example() {\n  const source$ = interval(100);\n\n  for await (const value of eachValueFrom(source$)) {\n    console.log(value);\n  }\n}\n```\n\nThis strategy will yield every single value the observable source emits, one at a time, until the observable completes or errors.\n\n#### Pros\n- All values are yielded\n- You get each value one at a time\n\n#### Cons\n- Creates more memory pressure if the body of the `for await` loop takes longer to come back around than the time between emissions from the observable source. If the observable emits faster than your loop can consume them, this may result in a memory leak.\n\n### bufferedValuesFrom (lossless)\n\n```ts\nasync function example() {\n  const source$ = interval(10);\n\n  for await (const buffer of bufferedValuesFrom(source$)) {\n    console.log(buffer);\n    await wait(1000);\n  }\n}\n```\n\nKeep an internal buffer of values emitted by the observable source, and yield the entire buffer to the `for await` loop. Continue this until the observable source completes or errors.\n\n#### Pros\n- All values are yielded\n- Lower memory pressure than `eachValueFrom`\n- Provides snapshots of what has happened since the last loop\n\n#### Cons\n- May still cause out of memory errors if the body of the `for await` loop is _extremely_ slow.\n- Perhaps less intuitive than `eachValueFrom`.\n\n### latestValueFrom (lossy)\n\n```ts\nasync function example() {\n  const source$ = interval(100);\n\n  for await (const value of latestValueFrom(source$)) {\n    console.log(value);\n  }\n}\n```\n\nThis strategy will immediately yield the most recently arrived value, or the very next one, if the `for await` loop is waiting and one has not arrived yet. Will continue\nto do so until the source observable completes or errors.\n\n#### Pros\n- No chance of memory leaks\n- Quick entry to the loop if a value is already available\n\n#### Cons\n- Will lose values if more than one value arrives while the loop body is being processed.\n\n### nextValueFrom (lossy)\n\n```ts\nasync function example() {\n  const source$ = interval(100);\n\n  for await (const value of nextValueFrom(source$)) {\n    console.log(value);\n  }\n}\n```\n\nWill wait for the very next value to arrive, then yield it. Will continue to do so until the source observable completes or errors.\n\n#### Pros\n- No chance of memory leaks\n\n#### Cons\n- Loop must wait for the next value to arrive, perhaps slowing down the process\n- Will lose values if values arrive while the loop is being processed.\n","repository":{"type":"git","url":"git+https://github.com/benlesh/rxjs-for-await.git"},"bugs":{"url":"https://github.com/benlesh/rxjs-for-await/issues"},"license":"MIT","versions":{"0.0.0":{"name":"rxjs-for-await","version":"0.0.0","description":"Add async-await for-await loop support to RxJS Observables","main":"./dist/cjs/index.js","module":"./dist/esm/index.js","es2015":"./dist/esm/index.js","types":"./dist/types/index.d.ts","scripts":{"build":"rm -rf ./dist && yarn tsc -p tsconfig.esm.json && yarn tsc && yarn tsc -p tsconfig.types.json","test":"jest","test:jest":"jest","test:tsc":"jest -c jest.tsc.config.js"},"repository":{"type":"git","url":"git+https://github.com/benlesh/rxjs-for-await.git"},"keywords":["RxJS","Observable","async-await","AsyncIterable","for-await"],"author":{"name":"Ben Lesh","email":"ben@benlesh.com"},"license":"MIT","bugs":{"url":"https://github.com/benlesh/rxjs-for-await/issues"},"homepage":"https://github.com/benlesh/rxjs-for-await#readme","devDependencies":{"@babel/core":"^7.8.7","@babel/preset-typescript":"^7.8.3","@types/jest":"^25.1.4","@types/node":"^13.9.1","jest":"^25.1.0","jest-runner-tsc":"^1.6.0","prettier":"^1.19.1","rxjs":"^6.0.0","ts-jest":"^25.2.1","typescript":"^3.8.3"},"peerDependencies":{"rxjs":"^6.0.0"},"gitHead":"29fb2fcafe653fb54a2cb28c6526185f867c103c","_id":"rxjs-for-await@0.0.0","_nodeVersion":"12.15.0","_npmVersion":"6.13.7","_npmUser":{"name":"anonymous","email":"ben@benlesh.com"},"dist":{"integrity":"sha512-9Mx5ubdUZm2tM6ZQsyl5rhXPksFYEW0PbqxSlBsPIexyDePym0UpjKMdtFsZFAgBynB+FUaACxi15JLxS8+0lA==","shasum":"39e78a962c6be99e5bc1353f4a715eda65d1c6e8","tarball":"http://repository.ncinga.com/nexus/content/groups/npm-all/rxjs-for-await/-/rxjs-for-await-0.0.0.tgz","fileCount":11,"unpackedSize":34342,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJecnoqCRA9TVsSAnZWagAAs3MP/joWysoxArfGvMb8XxSb\nk3jq40317HKPUFNUYL6DROaDFC5Staf/Jar2XNzHOIAb5SDlz7dUDnLzBNaZ\n/FI7FuRg66Oo20G+eAsjJFzS/jh4+EbZQ29f8WpPkdFhxgcyXwOGEqhhO/yl\nIyYdfDU/JCj3YztQd79cupLnbFSuxJzC784RNWR4DbXtSFZKQfS1oUNnmvbH\nKyj3u1u/46zsIE1Qo+/KKrasNRDXav//T0F6jJWufbqdN0Vu6XZuWynwhMWQ\n3Br2byaOkgACBKGDNY/4DeEdkhBVkhW6n+TBRwCbpe778Qh1fUYew4UjML22\nPzefpUfT28SamzE9GjWzH3KmlpOFx0pp8pGxUeGGBy55w1AUFkPFK0IbrQmF\n9oFMY6zB3o4Xu42J8RQghqqcepk0jnXO4SbU6k9cTLQGD9Lsga8TJiigra2M\nfKMkmSt7QxcdxK9HI3m1CbI6unlV857vwk9C0vk/CQfsxipd3QQqHig2ULjr\n0JOfzXSRW0R5TJogk0KbDhfKFZllQLpd0plk1nz2QpU/vWjRbMs7ebPCCO/i\n/N5UtbommkjoxE5OVhHU86WY8BeqUHvFfY40cUltNWZLsTRcAzgVc7fpGv9T\n5PaUCy28t3TOxR4wntdEyXJ8ZTXm1s7dMI9Q+DDdn9hORkjjd9xBq4PGVqqB\n6gMA\r\n=JytM\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCIFyIwvJKXqCGXXmKTVTm81Ndv7lLdnehwJnS3T3uimLOAiAjRyzbsEF31086FEicGey7lHBeOJjz8RKy0Dl+P3B/OA=="}]},"maintainers":[{"name":"anonymous","email":"ben@benlesh.com"}],"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/rxjs-for-await_0.0.0_1584560681892_0.6368427814996771"},"_hasShrinkwrap":false},"0.0.1":{"name":"rxjs-for-await","version":"0.0.1","description":"Add async-await for-await loop support to RxJS Observables","main":"./dist/cjs/index.js","module":"./dist/esm/index.js","es2015":"./dist/esm/index.js","types":"./dist/types/index.d.ts","scripts":{"build":"rm -rf ./dist && yarn tsc -p tsconfig.esm.json && yarn tsc && yarn tsc -p tsconfig.types.json","test":"jest","test:jest":"jest","test:tsc":"jest -c jest.tsc.config.js"},"repository":{"type":"git","url":"git+https://github.com/benlesh/rxjs-for-await.git"},"keywords":["RxJS","Observable","async-await","AsyncIterable","for-await"],"author":{"name":"Ben Lesh","email":"ben@benlesh.com"},"license":"MIT","bugs":{"url":"https://github.com/benlesh/rxjs-for-await/issues"},"homepage":"https://github.com/benlesh/rxjs-for-await#readme","devDependencies":{"@babel/core":"^7.8.7","@babel/preset-typescript":"^7.8.3","@types/jest":"^25.1.4","@types/node":"^13.9.1","jest":"^25.1.0","jest-runner-tsc":"^1.6.0","prettier":"^1.19.1","rxjs":"^6.0.0","ts-jest":"^25.2.1","typescript":"^3.8.3"},"peerDependencies":{"rxjs":"^6.0.0"},"gitHead":"29fb2fcafe653fb54a2cb28c6526185f867c103c","_id":"rxjs-for-await@0.0.1","_nodeVersion":"12.15.0","_npmVersion":"6.13.7","_npmUser":{"name":"anonymous","email":"ben@benlesh.com"},"dist":{"integrity":"sha512-G9njn7hKuxp8de2pUCKK1jSrmBRQXw2bVDWKG+VE3zkE1p/RH2iY6OR6fD+Rel0nnXeqhoWf8uduZ0W2jaOeOQ==","shasum":"5f345252ba7b35969b05ddc90185680927aec87a","tarball":"http://repository.ncinga.com/nexus/content/groups/npm-all/rxjs-for-await/-/rxjs-for-await-0.0.1.tgz","fileCount":22,"unpackedSize":464840,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJecnsRCRA9TVsSAnZWagAAGUAP+wUbyHxiS7ia/65eoLL5\nWjGj1gXC9lXMuH6d5vjtyB8VC9OgHc6EDKnpqzL4JEGELZq14L4E3p448qrv\nUEkiEhgYydfA1xUeZl7ptmM6Zm6zWEtpWrAvXyrS+rO1cMo8tcjInMwA0Oqq\nDLbjdwUStx9ver+B0w4EVPG8qp/aBdOv5s9AuQdjnYYpjhS4jSdBgNF6djQi\ne9NlQSmysAg0LasSyDww347V+2Yt03sa15fYMmM2a71YV03rrita8zjOk3yB\nSqgWevnvbkfO+P2cYeX4JBTQmSOZX46S8eWL8xcUxPCWGameTKkKMer7O8H5\nMvZ86+RAD2S3n3KUkGq0CqisQOcGB+hyIP4pyQoQebzYg0FmbwB+KGe2agva\nWqWURYhmTWs0dkuwR7iKzMBLV2DrqF7CDgGN791E0P5EVQmzRN8paehV0eJc\nzJs1UrmjAwTFkFdqAz3ABI2S6i3p+HDgw0NKlegkjvn/OR2gI2fMXeWONf1j\n1epHqUQE6SRxvL/6I90f11aXh1jE+Fp8H5OT3wxB2E3CeNWyO5GDUUMNuAeC\no1LaC8aSNg68dD9NUP2n2ZxehVp2FrJVpFEIlwvGpiHRXF6v56fuAUDx8rcK\nGsxkDOXI+HLPd/5vdN0hzrZ3B5DllATUaAI2iDPrleol/0CvZXIP98CRl1vM\nGYeB\r\n=EjGq\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIFmpzGypWz8aXRXAaavXkAuEr5Cv+TusZEgTk6n0OOzZAiEA443fKcFvBOAX3c1wpjnRIhKNVfsBbIMPAjrf3DGW8TA="}]},"maintainers":[{"name":"anonymous","email":"ben@benlesh.com"}],"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/rxjs-for-await_0.0.1_1584560912532_0.12892109736507185"},"_hasShrinkwrap":false},"0.0.2":{"name":"rxjs-for-await","version":"0.0.2","description":"Add async-await for-await loop support to RxJS Observables","main":"./dist/cjs/index.js","module":"./dist/esm/index.js","es2015":"./dist/esm/index.js","types":"./dist/types/src/index.d.ts","scripts":{"build":"rm -rf ./dist && yarn tsc -p tsconfig.esm.json && yarn tsc && yarn tsc -p tsconfig.types.json","test":"jest","test:jest":"jest","test:tsc":"jest -c jest.tsc.config.js"},"repository":{"type":"git","url":"git+https://github.com/benlesh/rxjs-for-await.git"},"keywords":["RxJS","Observable","async-await","AsyncIterable","for-await"],"author":{"name":"Ben Lesh","email":"ben@benlesh.com"},"license":"MIT","bugs":{"url":"https://github.com/benlesh/rxjs-for-await/issues"},"homepage":"https://github.com/benlesh/rxjs-for-await#readme","devDependencies":{"@babel/core":"^7.8.7","@babel/preset-typescript":"^7.8.3","@types/jest":"^25.1.4","@types/node":"^13.9.1","jest":"^25.1.0","jest-runner-tsc":"^1.6.0","prettier":"^1.19.1","rxjs":"^6.0.0","ts-jest":"^25.2.1","typescript":"^3.8.3"},"peerDependencies":{"rxjs":"^6.0.0"},"gitHead":"3645c819b0210f2affd8be738bb77cf34d19c91e","_id":"rxjs-for-await@0.0.2","_nodeVersion":"12.15.0","_npmVersion":"6.14.4","_npmUser":{"name":"anonymous","email":"ben@benlesh.com"},"dist":{"integrity":"sha512-IJ8R/ZCFMHOcDIqoABs82jal00VrZx8Xkgfe7TOKoaRPAW5nH/VFlG23bXpeGdrmtqI9UobFPgUKgCuFc7Lncw==","shasum":"26598a1d6167147cc192172970e7eed4e620384b","tarball":"http://repository.ncinga.com/nexus/content/groups/npm-all/rxjs-for-await/-/rxjs-for-await-0.0.2.tgz","fileCount":22,"unpackedSize":467877,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJewfmuCRA9TVsSAnZWagAAL7AP/RDmRcuyowPkYFFZyl2j\n2URQ8kbEsviLaE1l8E5UFuqbhY6LJO9Aotz8m8F7azD4mNfrDJwQLc3TSSYu\n72xbq2DndUbetgPLnHALlSSe6LqGC/jwim8sODzwOxqdtVJptBOlBpLSwDsk\ncmIjvtrRasy2UgMTNGf/VKpr1vfW7az8ffqn6z2MMGUKzDvDZxJa4TcA05Ft\nrATO9/jPpSNMK/6aywPQ3VoHpKyWHJ3g+O4qZXKjnfskQxSaK1tUZ6YAY6wp\nyRSNwzoDPOnwu6ffbvYJkj4yQxhiU9NKR44kkZb/baLsY36SoN4Qnk07lHEJ\n5TXZ7HlJuD1w5gLBfJOfmmO4dxf+BlaPc2Xu5a+M2tKxwB5OU2Ju1e7xh4H6\nXzJHp5W+/cO8stUXlcFVA8h2VjAw2QijZwU27v015vmb3IBj7bmKdx/PfMqa\ncUy5mUNFgmB2k5RXos2qSQ7wsFlNo8DAdvkIu5J/aHheJi04RIlmNiZlTNDq\n2XkQlDQf/T6rb00Rc6VvinYjzOETc7fLg26J5aFXXKrSGDRg/pFbWpHMD/rE\nEMAG3cxAUV7J4YbpxtdTu1LFTujenOstv6ZTmYuFmj6J6+iaM7dTHasDOJr2\nF/R9IWa7QhSnFhA7AgdlN0RE+RUsdpnyykWvgXr3fxU6wHOM1Q3cefyqMqj5\nurs3\r\n=Mp5E\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCIE7IhXek2Ec6pXdhjg/zpD6R1B/YmDEv+r17bDJYMduMAiAcj9uLkU+tvR4Fvg8x7d231dZvSuqNGodkrPv1uqYorA=="}]},"maintainers":[{"name":"anonymous","email":"ben@benlesh.com"}],"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/rxjs-for-await_0.0.2_1589770669625_0.9048084315930527"},"_hasShrinkwrap":false},"1.0.0":{"name":"rxjs-for-await","version":"1.0.0","description":"Add async-await for-await loop support to RxJS Observables","main":"./dist/cjs/index.js","module":"./dist/esm/index.js","es2015":"./dist/esm/index.js","types":"./dist/types/src/index.d.ts","sideEffects":false,"scripts":{"build":"rm -rf ./dist && yarn tsc -p tsconfig.esm.json && yarn tsc && yarn tsc -p tsconfig.types.json","test":"jest","test:jest":"jest","test:tsc":"jest -c jest.tsc.config.js","changelog":"conventional-changelog -p angular -i CHANGELOG.md -s","preversion":"git fetch --all","version":"npm run build && npm run changelog && git add ./CHANGELOG.md"},"repository":{"type":"git","url":"git+https://github.com/benlesh/rxjs-for-await.git"},"keywords":["RxJS","Observable","async-await","AsyncIterable","for-await"],"author":{"name":"Ben Lesh","email":"ben@benlesh.com"},"license":"MIT","bugs":{"url":"https://github.com/benlesh/rxjs-for-await/issues"},"homepage":"https://github.com/benlesh/rxjs-for-await#readme","devDependencies":{"@babel/core":"^7.8.7","@babel/preset-typescript":"^7.8.3","@types/jest":"^27.0.2","@types/node":"^13.9.1","conventional-changelog-cli":"^2.1.1","jest":"^27.3.1","jest-runner-tsc":"^1.6.0","prettier":"^1.19.1","rxjs":"7.4.0","ts-jest":"^27.0.7","typescript":"^4.4.4"},"peerDependencies":{"rxjs":"^7.0.0"},"gitHead":"ec7513747e7e50bd98a9fb327a1545308ca6b85e","_id":"rxjs-for-await@1.0.0","_nodeVersion":"14.15.4","_npmVersion":"7.7.6","dist":{"integrity":"sha512-MJhvf1vtQaljd5wlzsasvOjcohVogzkHkUI0gFE9nGhZ15/fT2vR1CjkLEh37oRqWwpv11vHo5D+sLM+Aw9Y8g==","shasum":"89f4b2f2a95f93ab36f1e9fb8b5d0637bc9f8ca8","tarball":"http://repository.ncinga.com/nexus/content/groups/npm-all/rxjs-for-await/-/rxjs-for-await-1.0.0.tgz","fileCount":23,"unpackedSize":145366,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCIHxcVvsLETfc0fUBfodNM739t345C2/cGP3m5iq7SVT9AiAlyctv1B+F7p0IKvo/ZD1Aqfo2rkGT2NRZOLdb03P29w=="}]},"_npmUser":{"name":"anonymous","email":"ben@benlesh.com"},"directories":{},"maintainers":[{"name":"anonymous","email":"ben@benlesh.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/rxjs-for-await_1.0.0_1636511348886_0.2786431288624611"},"_hasShrinkwrap":false}},"name":"rxjs-for-await","time":{"created":"2020-03-18T19:44:41.891Z","0.0.0":"2020-03-18T19:44:42.055Z","modified":"2022-05-16T08:54:08.350Z","0.0.1":"2020-03-18T19:48:32.624Z","0.0.2":"2020-05-18T02:57:49.714Z","1.0.0":"2021-11-10T02:29:09.040Z"},"readmeFilename":"README.md","homepage":"https://github.com/benlesh/rxjs-for-await#readme"}