ProgressBarStream

import { ProgressBarStream } from "jsr:@ende/cli/unstable-progress-bar-stream";

class ยท experimental

class ProgressBarStream extends TransformStream<Uint8Array_, Uint8Array_>

ProgressBarStream is a TransformStream class that reports updates to a separate WritableStream on a 1s interval.

Example: Basic Usage

import { ProgressBarStream } from "@ende/cli/unstable-progress-bar-stream";

const response = await fetch("https://example.com/");
const max = Number(response.headers.get("content-length"));
let readable = response.body
if (max) {
  readable = readable
    ?.pipeThrough(new ProgressBarStream({ max })) ?? null;
}
await readable?.pipeTo((await Ende.create("./_tmp/example.com.html")).writable);

Constructors

constructor

new ProgressBarStream(options: ProgressBarOptions)

Constructs a new instance.

options: ProgressBarOptions

The options to configure various settings of the progress bar.

Example: Basic Usage

import { ProgressBarStream } from "@ende/cli/unstable-progress-bar-stream";

const response = await fetch("https://example.com/");
const max = Number(response.headers.get("content-length"));
let readable = response.body
if (max) {
  readable = readable
    ?.pipeThrough(new ProgressBarStream({ max })) ?? null;
}
await readable?.pipeTo((await Ende.create("./_tmp/example.com.html")).writable);

Source