TerminalDimensions
TerminalDimensions is the object returned by getProcessSize() and stored in the size constant. It exposes the terminal's width and height in multiple pre-calculated forms — original, half, third, two-thirds, and full — so you never have to do the maths yourself.
Type Definitions
interface TerminalSize {
og: number; // original dimension
half: number;
third: number;
twoThirds: number;
full: number; // same as og
}
type TerminalDimensions = {
width: TerminalSize;
height: TerminalSize;
}
Usage
import { size, getProcessSize } from "ts-better-console";
// size: static snapshot captured at import time
console.log(size.width.og); // e.g. 220 columns
console.log(size.width.half); // 110
// getProcessSize(): fresh reading each call
const dims = getProcessSize();
console.log(dims.height.og); // e.g. 50 rows
Want to support this project?
If you find ts-better-console useful and want to support its development, consider starring the GitHub repository or buying me a coffee! Your support helps me dedicate more time to improving the library and adding new features.
Want to contribute to this project?
Contributions are welcome! If you're interested in improving the library, fixing bugs, or adding new features, feel free to check out the GitHub repository and submit a pull request. Whether you're a seasoned developer or new to open source, your contributions can make a difference!