{"_id":"@art-of-coding/stream-utils","_rev":"3-bdf571b2edcced716c78861b520b6fe4","name":"@art-of-coding/stream-utils","dist-tags":{"latest":"0.0.3"},"versions":{"0.0.1":{"name":"@art-of-coding/stream-utils","version":"0.0.1","description":"Redis Stream utilities for node.js","main":"./dist/index.js","author":{"name":"Michiel van der Velde","email":"michiel@michielvdvelde.nl"},"homepage":"http://github.com/Art-of-Coding/stream-utils","repository":{"type":"git","url":"git+https://github.com/Art-of-Coding/stream-utils.git"},"engines":{"node":">=14"},"license":"MIT","dependencies":{"ioredis":"^4.27.6"},"devDependencies":{"@types/ioredis":"^4.26.4","@types/node":"^15.12.2"},"bugs":{"url":"https://github.com/Art-of-Coding/stream-utils/issues"},"_id":"@art-of-coding/stream-utils@0.0.1","_nodeVersion":"14.8.0","_npmVersion":"6.14.7","dist":{"integrity":"sha512-UADTyECYKyvI2ZHRu0zvorZ//grNTFjkUVlseCBDmisF3RzkK+lFLgzG5CRWZem35Lj8ZzwlKuaHoAtlkAFrzQ==","shasum":"d6d3178052cd431efcaaf2de09aa6f55ca43dfea","tarball":"https://registry.npmjs.org/@art-of-coding/stream-utils/-/stream-utils-0.0.1.tgz","fileCount":17,"unpackedSize":11467,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJgxiYCCRA9TVsSAnZWagAAQVUP/3kI0dDNsltgxCeqhdFb\nqmQzoP95BnNvqUysU1NbbOwL9I1zAI4OZLzxttO0SvFg/mcfNVlLn/tJOXnj\nC5Psh1+zScoHGfj3G8BegOJAJ1nmDwF8kWwlY8FM/enIgtpzEq1Je92wy8Ky\nlGYf8DZ9BNS+dJ7ueR6Bbc8nhIN4H5i20+4O2EtH7Pf1ZGUNSz1gvMVbn3nf\nqK8YCdcFLZa7Tg4ayWU9799natm3Q4X2cttz/DD4zgzLvbmbl37lrz9gW93i\nwlC285ilBxzKSPOOaNHXkiQJgcCJNcPPbl+aEB9LkMpetqkyzJ43Eli9IVLt\nU9Q2Q5RfhtvNMbJvt4ZKSjPk8BVSL5dXQLNnsFxibVbUjR2QGnKBnz2YuCDn\ndXnMaTk4K1t4s0DKhWw/A8lhXYauz/+v4lCzdubmeDdjidpLYkJp0mQ4q2nv\n5T1Tq0YvlExM8ahl55xKeuuMysiTVxnTauIxln+Yeh7k7LDHaIBDDCeH1E+3\n+GEpv896Xic/p/7ty1uPbAVcczgdf+fgm+HltjobjdG6yxhWl4zJKA0mjPMr\nAe8m3RpxqfeJaAc9g010B6jAd819Xg+h1G1w4tNliBKx+uJ5jTCaCGb1TkZi\nbhOl3n357yGX/lwSOHg/c9XFmFZytx+mMeK9T/V6EleftlPPKaaM6KzhBc1v\nMmDu\r\n=dqou\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEYCIQDNknqdo7VtIscnETs2LC1iSndV4l1LJcmMhMUroDJgsQIhAPDMw6E05glNI1iw+nHpWCM+l2EalG/vuXW3Ryg2E8sw"}]},"_npmUser":{"name":"michielvdvelde","email":"michiel@michielvdvelde.nl"},"directories":{},"maintainers":[{"name":"michielvdvelde","email":"michiel@michielvdvelde.nl"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/stream-utils_0.0.1_1623598594810_0.7381682715626878"},"_hasShrinkwrap":false},"0.0.2":{"name":"@art-of-coding/stream-utils","version":"0.0.2","description":"Redis Stream utilities for node.js","main":"./dist/index.js","author":{"name":"Michiel van der Velde","email":"michiel@michielvdvelde.nl"},"homepage":"http://github.com/Art-of-Coding/stream-utils","repository":{"type":"git","url":"git+https://github.com/Art-of-Coding/stream-utils.git"},"engines":{"node":">=14"},"license":"MIT","dependencies":{"ioredis":"^4.27.6"},"devDependencies":{"@types/ioredis":"^4.26.4","@types/node":"^15.12.2"},"gitHead":"234c739e12ce3f0e0e7832f1be683d8b49b84550","bugs":{"url":"https://github.com/Art-of-Coding/stream-utils/issues"},"_id":"@art-of-coding/stream-utils@0.0.2","_nodeVersion":"14.8.0","_npmVersion":"6.14.7","dist":{"integrity":"sha512-OTb5WxTO4u8ebdmEDTNRHf9CasFKOiHmMBoo9Sg0Ci3Gw6Dx/GOv7j3jw5Rf/jAwRBGmEph1x2TgYx9jVBvHhA==","shasum":"b100aff556255943525792779888b491a40f00b4","tarball":"https://registry.npmjs.org/@art-of-coding/stream-utils/-/stream-utils-0.0.2.tgz","fileCount":19,"unpackedSize":18202,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJgxn/tCRA9TVsSAnZWagAAy/EP/ji2AO4iVeYk+nI+L+BB\nOGFS2A2bJMJDgGhSkMXufQSupuvFfPPKp89/binb96M/Rlalr7aGSPBmggR5\nRtSD1CmxsW+zj/P1Jpz9EUVA0QiIMwGAb9jpMyChq+WC/2bQ/b3+a94U+Zds\ntV2yju/0L/yuaNsB61v6nVCuZtUbos1BXEzkQuZ3frq3FYUe0As0C19rdTR7\n982/JoL8U2cRuccpt/bIcncFh45oXzFarkuC64OVvSaG21jKPrhVxVMF1425\nazhKp5hPjiJhNquVp5OsGoDKw9/UT39cwnRVFrfHHoSItgwlaKzQ9AY0zsOC\nFxKzuBhECoTbfIuVzngPti1GzXuRlJ3HrYc6gvfs7G4E4/tGj5a9A6IWenO6\n6vJyDpCwE7NoBd4zCffHqMSDvKjq1/HkaCBfkYx6k4hZiWlcahkK4UGcAMU5\n2Y8kkhY82qGsFLii0LShKPw7ZZ7ro3Sa4uRQLNGnstsl0IHRs+Z+yJ/ZJD/3\nZGC7Sav+GZnXiA7cuS6rYv6zTbIhTfOa+/P4GXZuwfP3fiODJdio1OCzqntl\nUZO8eTWPTZLD3wKcDiET3sX0S2lAaqri5x+nyB2WYRVklw7AuKx5hCcKI9t9\ncJdYCdst2stjQb7TNQUDkXAExNWJ75Rgceezl7F3cDrfzDWYNKdD1iXK9br/\nuj61\r\n=wKjx\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEYCIQCIlDGV20ZIqZb/Xn384v0IO+N3OEErkfBKskwNvxdiAgIhAJ3em4fiB61qZIsCJSkyYkJ8L5wTRPqZmCrpO1w76k3D"}]},"_npmUser":{"name":"michielvdvelde","email":"michiel@michielvdvelde.nl"},"directories":{},"maintainers":[{"name":"michielvdvelde","email":"michiel@michielvdvelde.nl"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/stream-utils_0.0.2_1623621613691_0.6084358837926733"},"_hasShrinkwrap":false},"0.0.3":{"name":"@art-of-coding/stream-utils","version":"0.0.3","description":"Redis Stream utilities for node.js","main":"./dist/index.js","author":{"name":"Michiel van der Velde","email":"michiel@michielvdvelde.nl"},"homepage":"http://github.com/Art-of-Coding/stream-utils","repository":{"type":"git","url":"git+https://github.com/Art-of-Coding/stream-utils.git"},"engines":{"node":">=14"},"license":"MIT","dependencies":{"ioredis":"^4.27.6"},"devDependencies":{"@types/ioredis":"^4.26.4","@types/node":"^15.12.2"},"gitHead":"bb8ef5f3da466aac8a3a10eee58723bf3e9cb50a","bugs":{"url":"https://github.com/Art-of-Coding/stream-utils/issues"},"_id":"@art-of-coding/stream-utils@0.0.3","_nodeVersion":"14.8.0","_npmVersion":"6.14.7","dist":{"integrity":"sha512-3hRF4ptmwDDszhTeDmbu5NYTAcmnP2LE2y+H08pn1+RN6zzFPggY2u0aNv4XcQ4blhoxvkhhgVIgjpkohEB+4Q==","shasum":"bdaa1c37d8aa295585e11e942110d00cf73f9122","tarball":"https://registry.npmjs.org/@art-of-coding/stream-utils/-/stream-utils-0.0.3.tgz","fileCount":21,"unpackedSize":20078,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJgzKznCRA9TVsSAnZWagAAxpIP+QCclUj8fw+GtBRelnAC\naV/zfGesDxD5slbVP+8RjdndvYzq1MvPLvoUHsLlKM9l3jCGGkAju70hiYAy\noiBvGIqc3iO/JpGrMC2TSG8z7yRWR4iWs8KwbmsWIubUvF5+g+OPZBBJFqie\n3R/f2K1TmqdVDZnrPZRUHBYinAIMerBdHjp0tsWheAT50k0FbslPiuSs4Sju\nbL5HM59yM2NDnFsttE9iAMueJvpSr7PXWG7C0i3UBopMlNrjw6bH1xq5Z7H/\n/aCUNxzM7dmsdcv763xkENPjDOb+R/bGUpFGN96EAxR5IsVONYMh4/GnwU3u\nlEKH6Vcb2b7c79ILIqsTL/jNSS56zSC7OVarWGjgSGGVo9tg1hGtNkfNfmBq\nNtuXj/L2Wqfs5uB3Q+XWjbeFpUoAIGioGGx21jy/UgTIaQ+3giWso76hc+wN\nkd90GQFnvRBczMTA77ysvaJ2U5VPeALrvBWoVysEPdIVjAIwLnWTqoe3kPkL\nV18Y87+sRZ1NIvkSxcgrqYhDMHx+OyEsco9kLwPZPy9MULqTBMr+6BVrfhHT\nLa4f0BYvbw7lzA6GbyV/QDvFUn7HPrg+rKqnGTh4Xgia6211jfoOIiLu4BC3\na+Bq7gYlMCWXdrTxs4bOuigiVZ1lZg8EEPrA2apQcI5ieWKhkNo5jsJo1wv8\nbi1h\r\n=axCN\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEYCIQCwTat9re/j7BGVrMKJ5aL9s9yQCBPAFGcWZWeQS5H3ygIhAPHbKzhZMBXaWLR61KRL8GQvJ4OE0R/XMR8D/M3q3yEN"}]},"_npmUser":{"name":"michielvdvelde","email":"michiel@michielvdvelde.nl"},"directories":{},"maintainers":[{"name":"michielvdvelde","email":"michiel@michielvdvelde.nl"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/stream-utils_0.0.3_1624026342919_0.07079279501787838"},"_hasShrinkwrap":false}},"time":{"created":"2021-06-13T15:36:34.603Z","0.0.1":"2021-06-13T15:36:34.963Z","modified":"2022-04-04T15:35:55.296Z","0.0.2":"2021-06-13T22:00:13.834Z","0.0.3":"2021-06-18T14:25:43.062Z"},"maintainers":[{"name":"michielvdvelde","email":"michiel@michielvdvelde.nl"}],"description":"Redis Stream utilities for node.js","homepage":"http://github.com/Art-of-Coding/stream-utils","repository":{"type":"git","url":"git+https://github.com/Art-of-Coding/stream-utils.git"},"author":{"name":"Michiel van der Velde","email":"michiel@michielvdvelde.nl"},"bugs":{"url":"https://github.com/Art-of-Coding/stream-utils/issues"},"license":"MIT","readme":"# Redis Stream Utilities\n\nI find that in my work with Redis streams I often have to write the same\nfunctionality, just a little different for the given use case. `stream-utils` is\nan attempt to consolidate these utility functions so I (and others) can use them\nmore easily.\n\nDocumentation is - except for the examples below - currently absent. The source\ncode itself should give you a pretty good idea of what options are supported.\n\nThis module is a work-in-progress. Bug reports and pull requests are more than\nwelcome!\n\n## Install\n\n```\nnpm i @art-of-coding/stream-utils\n```\n\n## Usage\n\n### Connection Pool\n\nA basic and naive Redis connection pool.\n\n```typescript\nimport IORedis from \"ioredis\";\nimport { ConnectionPool } from \"@art-of-coding/stream-utils\";\n\nconst connection = new IORedis();\nconst pool = new ConnectionPool({ connection });\n\n// somewhere else...\n\nconst [connection, release] = pool.get();\n// do something with the connection...\n// and release it back into the pool\nrelease();\n```\n\n### Streams Reader\n\nThis little piece of code may become the successor to\n[redis-streams-manager](https://github.com/MichielvdVelde/redis-streams-manager)\nand my favorite way to work with streams.\n\nThe core of the reader is `xread` as an async iterator. The reader manages\nmultiple streams automatically, starting and stopping consumption as required.\nYou can use the same reader to consume multiple streams simultaneously.\n\nThe reader makes use of the blocking version of `xread`, so it requires a\ndedicated Redis connection.\n\n```typescript\nimport IORedis from \"ioredis\";\nimport { StreamsReader } from \"@art-of-coding/stream-utils\";\n\nconst blockingConnection = new IORedis();\nconst reader = new StreamsReader(blockingConnection, {\n  count: 5, // defaults to max 5 entries per stream per xread command\n  blockingTimeout: 5000, // defaults to 5000 ms\n});\n\nconst ac = new AbortController();\n\nfor await (\n  const [entry, id] of reader.read(\"stream-key\", { id: \"$\", signal: ac.signal })\n) {\n  // do something with the entry...\n}\n```\n\n### xrange\n\nThe [`xrange`](https://redis.io/commands/xrange) command as an async iterator.\n\n```typescript\nimport IORedis from \"ioredis\";\nimport { xrange } from \"@art-of-coding/stream-utils\";\n\nconst connection = new IORedis();\n\nfor await (const [entry, id] of xrange(connection, \"key\")) {\n  // do something with the entry...\n}\n```\n\n### xrevrange\n\nThe [`xrevrange`](https://redis.io/commands/xrevrange) command as an async\niterator.\n\n```typescript\nimport IORedis from \"ioredis\";\nimport { xrevrange } from \"@art-of-coding/stream-utils\";\n\nconst connection = new IORedis();\n\nfor await (const [entry, id] of xrevrange(connection, \"key\")) {\n  // do something with the entry...\n}\n```\n\n### xread\n\nThe [`xread`](https://redis.io/commands/xread) command as an async iterator.\n\n```typescript\nimport IORedis from \"ioredis\";\nimport { xread } from \"@art-of-coding/stream-utils\";\n\nconst connection = new IORedis();\nconst ac = new AbortController();\n\nfor await (\n  const [entry, id] of xread(connection, \"key\", { signal: ac.signel })\n) {\n  // do something with the entry...\n\n  // call the abort method to break out of the loop\n  ac.abort();\n}\n```\n\n### xadd\n\nSimpler way to use `xadd`.\n\nSee the source code to find out which options are supported.\n\n```typescript\nimport IORedis from \"ioredis\";\nimport { xadd } from \"@art-of-coding/stream-utils\";\n\nconst connection = new IORedis();\n\nconst value = {\n  some: \"value\",\n};\n\nconst id = await xadd(connection, \"key\", value, {\n  maxLength: 10000, // optional\n  maxLengthType: \"~\",\n});\n```\n\n## License\n\nCopyright 2021 [Michiel van der Velde](https://michielvdvelde.nl).\n\nThis software is licensed under [the MIT License](LICENSE).\n","readmeFilename":"README.md"}