braid-protocol
braid-protocol copied to clipboard
Use node-web-streams
The client can be used in the browser or in a nodejs process. We use two separate mechanisms to read the stream in each case. A potentially more elegant solution was identified here:
// On nodejs, this requires "npm install node-fetch node-web-streams"
if (typeof window === 'undefined') {
var fetch = require('node-fetch')
var Headers = fetch.Headers
var to_whatwg_stream = require('node-web-streams').toWebReadableStream
module.exports = braid_fetch
}