Stream => JQ => Stream
npm install --save streamjq
May need to install the following packages:
apt-get install libtool autoconf build-essential
May need to install the following if installation fails
sudo apt-get install autoconf libtool automake build-essential
const jq = require('streamjq')
const transformedStream = jq([READABLE_STREAM], [JQ_FILTER])
transformedStream.pipe(WRITABLE_STREAM)
const fetch = require('node-fetch');
const jq = require('streamjq')
const stream = require('stream')
fetch("https://genesis.bitdb.network/q/1FnauZ9aUH2Bex6JzdcV4eNX7oLSSEbxtN/ewogICJ2IjogMywKICAicSI6IHsKICAgICJmaW5kIjoge30sCiAgICAibGltaXQiOiAxMAogIH0KfQ==", { headers: { key: "1KJPjd3p8khnWZTkjhDYnywLB2yE1w5BmU" } })
.then(function(res) {
return res.json()
})
.then(function(res) {
let s = new stream.Readable()
s.push(JSON.stringify(res.c))
s.push(null);
jq(s, "[.[] | { b0: .out[0].b0, blk: .blk }]").pipe(process.stdout)
})