UNPKG

1.23 kBTypeScriptView Raw
1/// <reference types="node" />
2
3declare module "window-size" {
4 import { WriteStream } from "fs";
5
6 const windowSize: windowSize.Size & {
7 /** Get terminal window's size with available channels. */
8 get(options?: windowSize.WindowSizeOptions): windowSize.Size;
9 /** Get terminal window's size with `process.env.COLUMNS` and `process.env.ROWS`. */
10 env(): windowSize.Size;
11 /** Get terminal window's size with `tty` module */
12 tty(options: windowSize.TtySizeOptions): windowSize.Size;
13 tput(): windowSize.Size;
14 win(): windowSize.Size;
15 };
16 export = windowSize;
17 namespace windowSize {
18 export interface Size {
19 width: number;
20 height: number;
21 type: string;
22 }
23
24 /** Options of inner function `streamSize`. */
25 type StreamSizeOptions = Record<string, WriteStream>;
26
27 /** Options of function `windowSize.tty`. */
28 interface TtySizeOptions {
29 tty?: {
30 getWindowSize?: (out: WriteStream) => [number, number];
31 };
32 }
33
34 /** Options of function `windowSize.get` */
35 type WindowSizeOptions = StreamSizeOptions & TtySizeOptions;
36 }
37}