StaticLine

import { StaticLine } from "jsr:@ende/cli/unstable-static-line";

class ยท experimental

class StaticLine

StaticLine is a class that assigns a line in the terminal for you to write to and that won't be overwritten by console.log.

Example: Usage

import { delay } from "@ende/async/delay";
import { StaticLine } from "@ende/cli/unstable-static-line";

const id = setInterval(() => console.log(Math.random()), 1000);

const line = new StaticLine();
await line.write("Hello World!");
await delay(1500);
await line.write("How are you?");
await delay(1500);
await line.write("Doing good?");
await delay(1500);
await line.releaseLine();

Constructors

constructor

new StaticLine(on: "top" | "bottom" = bottom)

Constructs a new instance.

on: "top" | "bottom" = bottom

What side of the terminal the line should be on.

Methods

write

write(line: string): Promise<void>

Overwrites the contents of the line.

line: string

The new content to write.

Returns

A promise that resolves when the line is written.

Example: Usage

import { delay } from "@ende/async/delay";
import { StaticLine } from "@ende/cli/unstable-static-line";

const id = setInterval(() => console.log(Math.random()), 1000);

const line = new StaticLine();
await line.write("Hello World!");
await delay(1500);
await line.write("How are you?");
await delay(1500);
await line.write("Doing good?");
await delay(1500);
await line.releaseLine();

releaseLine

releaseLine(): Promise<void>

Releases the line so other content can use it.

Returns

A promise that resolves when the line is released.

Example: Usage

import { delay } from "@ende/async/delay";
import { StaticLine } from "@ende/cli/unstable-static-line";

const id = setInterval(() => console.log(Math.random()), 1000);

const line = new StaticLine();
await line.write("Hello World!");
await delay(1500);
await line.write("How are you?");
await delay(1500);
await line.write("Doing good?");
await delay(1500);
await line.releaseLine();

Source