Skip to content

Instantly share code, notes, and snippets.

@ci7lus
Created December 2, 2021 13:30
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ci7lus/f3304ad17db8ae4121a0b8ed6ac82a99 to your computer and use it in GitHub Desktop.
Save ci7lus/f3304ad17db8ae4121a0b8ed6ac82a99 to your computer and use it in GitHub Desktop.
import { chain } from "stream-chain"
import { parser } from "stream-json"
import { streamArray } from "stream-json/streamers/StreamArray"
import { MirakurunAPI } from "../infra/mirakurun"
const main = async () => {
const client = new MirakurunAPI({
baseUrl: "http://192.168.0.10:40772/api",
})
const claimStream = await client.events.getEventsStream(
"program",
undefined,
{
responseType: "stream",
}
)
const pipeline = chain([claimStream.data as any, parser(), streamArray()])
pipeline.on("data", () => (claimStream.data as any).destroy())
pipeline.destroy()
}
main()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment