declare const response: Http.ClientResponse;
pipe(
response.stream,
Stream.broadcast(2, 1),
Effect.map(Tuple.mapSecond(
flow(
Stream.map(u8arr => u8arr.length),
Stream.scan(0, Number.sum),
Stream.throttle(Duration.seconds(1)), // emit the latest value every 1 sec, drop other intermediate values
Stream.tap(x => Ef.log(`Downloaded ${x} bytes`))
)
),
Ef.map(([responseStream, logStream]) => Stream.merge(responseStream, logStream)),
Ef.flatMap(Stream.run(fileSystem.sink(outputPath, { flag: 'w' })))
);
declare const response: Http.ClientResponse;
pipe(
response.stream,
Stream.broadcast(2, 1),
Effect.map(Tuple.mapSecond(
flow(
Stream.map(u8arr => u8arr.length),
Stream.scan(0, Number.sum),
Stream.throttle(Duration.seconds(1)), // emit the latest value every 1 sec, drop other intermediate values
Stream.tap(x => Ef.log(`Downloaded ${x} bytes`))
)
),
Ef.map(([responseStream, logStream]) => Stream.merge(responseStream, logStream)),
Ef.flatMap(Stream.run(fileSystem.sink(outputPath, { flag: 'w' })))
);