API

Index

Classes

Interfaces

Type aliases

Variables

Functions

Object literals

Type aliases

ForEachMessageCallback

Ƭ ForEachMessageCallback: function

Type declaration:

▸ (message: Message‹Meta›, name: string, allMessages: MessageMap‹Meta›): void

Parameters:

Name Type
message Message‹Meta›
name string
allMessages MessageMap‹Meta›

MessageMap

Ƭ MessageMap: Map‹string, Message‹Meta››


NoMeta

Ƭ NoMeta: undefined

Variables

Const sharedCursor

sharedCursor: Cursor = createCursor()


Const sharedStdinMuter

sharedStdinMuter: undefined | Muter = createStdinMuter()

Functions

createCursor

createCursor(): Cursor

Returns an object capable of showing and hiding the CLI cursor.

remarks This is a thin wrapper around cli-cursor.

Returns: Cursor


createSpinnerLoop

createSpinnerLoop(spinner: Spinner): SpinnerLoop

Returns an object capable of managing setInterval calls related to a spinner.

remarks This implementation was based on code from spinnies (MIT).

Parameters:

Name Type
spinner Spinner

Returns: SpinnerLoop


createStdinMuter

createStdinMuter(): Muter | undefined

Returns an object capable of muting stdin output.

remarks This implementation was based on StdinDiscarder from ora (MIT).

Returns: Muter | undefined


defaultRender

defaultRenderMeta›(message: Message‹Meta›, frame: string | null): string

The function used to render messages if a render function is not defined by the Message object.

Type parameters:

Meta

Parameters:

Name Type
message Message‹Meta›
frame string | null

Returns: string


tabStop

tabStop(input: string[], columns: number): string

Simulate tab stops using spaces

remarks tabStop can be used instead of actual tabs to sidestep a TTY quirk.

When Twisters overwrites a line of text, it only clears from the end of the new text to the end of the terminal line (as opposed to clearing the entire line before writing which can cause a flickering effect).

When a tab (\t) character is written to the stream, the cursor advances without overwriting the text, which can cause garbage text to remain on the line in some cases.

Use tabStop to create the illusion of regular tab breaks by inserting the required number of spaces (assumes 8 character wide tab stop by default).

example util/tab-stop.js

tabStop(line.split('\t'));

Parameters:

Name Type Default
input string[] -
columns number 8

Returns: string


terminalSupportsUnicode

terminalSupportsUnicode(): boolean

The default command prompt and PowerShell in Windows do not support Unicode characters. However, the VS Code integrated terminal and the Windows Terminal both do, so this function takes the TERM_PROGRAM and WT_SESSION environment variables into account.

remarks This implementation was extracted from spinnies (MIT).

Returns: boolean


wrapText

wrapText(text: string, columns: number, wordWrap: boolean): string

Wrap text to the specified column width by inserting line breaks.

remarks This is a thin wrapper around wrap-ansi.

Parameters:

Name Type Default
text string -
columns number 80
wordWrap boolean false

Returns: string

Object literals

Const dashes

dashes: object

frames

frames: string[] = ['-', '_']

interval

interval: number = 80


Const dots

dots: object

frames

frames: string[] = ['⠋', '⠙', '⠹', '⠸', '⠼', '⠴', '⠦', '⠧', '⠇', '⠏']

interval

interval: number = 50