log-fetch
Version:
Implementation of Fetch that uses the Dat SDK for loading p2p content
28 lines (19 loc) • 481 B
JavaScript
const eosp = require('end-of-stream-promise')
const { Readable } = require('streamx')
run()
.catch((e) => process.nextTick(() => {
throw e
}))
async function run () {
const fetch = require('./')()
try {
const url = process.argv[2]
const response = await fetch(url)
const stream = Readable.from(response.body)
stream.pipe(process.stdout)
await eosp(stream)
} finally {
fetch.close()
}
}