AnsiDoc.ts overview
Since v1.0.0
Exports Grouped by Category
- alignment
- alternative layouts
- annotations
- combinators
- commands
- concatenation
- constructors
- destructors
- filling
- flattening
- instances
- matching
- model
- primitives
- reactive layouts
- refinements
- separation
- utilities
- utils
alignment
align
Signature
declare const align: <A>(self: Doc<A>) => Doc<A>
Since v1.0.0
encloseSep
Signature
declare const encloseSep: {
<A, B, C>(left: Doc<A>, right: Doc<B>, sep: Doc<C>): <D>(docs: Iterable<Doc<D>>) => Doc<A | B | C | D>
<A, B, C, D>(docs: Iterable<Doc<D>>, left: Doc<A>, right: Doc<B>, sep: Doc<C>): Doc<A | B | C | D>
}
Since v1.0.0
hang
Signature
declare const hang: { (indent: number): <A>(self: Doc<A>) => Doc<A>; <A>(self: Doc<A>, indent: number): Doc<A> }
Since v1.0.0
indent
Signature
declare const indent: { (indent: number): <A>(self: Doc<A>) => Doc<A>; <A>(self: Doc<A>, indent: number): Doc<A> }
Since v1.0.0
list
Signature
declare const list: <A>(docs: Iterable<Doc<A>>) => Doc<A>
Since v1.0.0
nest
Signature
declare const nest: { (indent: number): <A>(self: Doc<A>) => Doc<A>; <A>(self: Doc<A>, indent: number): Doc<A> }
Since v1.0.0
tupled
Signature
declare const tupled: <A>(docs: Iterable<Doc<A>>) => Doc<A>
Since v1.0.0
alternative layouts
flatAlt
Signature
declare const flatAlt: {
<B>(that: Doc<B>): <A>(self: Doc<A>) => Doc<B | A>
<A, B>(self: Doc<A>, that: Doc<B>): Doc<A | B>
}
Since v1.0.0
group
Signature
declare const group: <A>(self: Doc<A>) => Doc<A>
Since v1.0.0
union
Signature
declare const union: {
<B>(that: Doc<B>): <A>(self: Doc<A>) => Doc<B | A>
<A, B>(self: Doc<A>, that: Doc<B>): Doc<A | B>
}
Since v1.0.0
annotations
alterAnnotations
Signature
declare const alterAnnotations: {
<A, B>(f: (a: A) => Iterable<B>): (self: Doc<A>) => Doc<B>
<A, B>(self: Doc<A>, f: (a: A) => Iterable<B>): Doc<B>
}
Since v1.0.0
annotate
Signature
declare const annotate: { <A>(annotation: A): (self: Doc<A>) => Doc<A>; <A>(self: Doc<A>, annotation: A): Doc<A> }
Since v1.0.0
reAnnotate
Signature
declare const reAnnotate: {
<A, B>(f: (a: A) => B): (self: Doc<A>) => Doc<B>
<A, B>(self: Doc<A>, f: (a: A) => B): Doc<B>
}
Since v1.0.0
unAnnotate
Signature
declare const unAnnotate: <A>(self: Doc<A>) => Doc<never>
Since v1.0.0
combinators
map
Signature
declare const map: { <A, B>(f: (a: A) => B): (self: Doc<A>) => Doc<B>; <A, B>(self: Doc<A>, f: (a: A) => B): Doc<B> }
Since v1.0.0
commands
cursorBackward
Moves the cursor backward by the specified number of columns
(default 1
) relative to the current cursor position.
If the cursor is already at the edge of the screen, this has no effect.
Signature
declare const cursorBackward: (columns?: number) => AnsiDoc
Since v1.0.0
cursorDown
Moves the cursor down by the specified number of lines
(default 1
) relative to the current cursor position.
If the cursor is already at the edge of the screen, this has no effect.
Signature
declare const cursorDown: (lines?: number) => AnsiDoc
Since v1.0.0
cursorForward
Moves the cursor forward by the specified number of columns
(default 1
) relative to the current cursor position.
If the cursor is already at the edge of the screen, this has no effect.
Signature
declare const cursorForward: (columns?: number) => AnsiDoc
Since v1.0.0
cursorHide
Hides the cursor.
Signature
declare const cursorHide: AnsiDoc
Since v1.0.0
cursorLeft
Moves the cursor to the first column of the current row.
Signature
declare const cursorLeft: AnsiDoc
Since v1.0.0
cursorNextLine
Moves cursor to beginning of the line the specified number of rows down (default 1
).
Signature
declare const cursorNextLine: (rows?: number) => AnsiDoc
Since v1.0.0
cursorPrevLine
Moves cursor to beginning of the line the specified number of rows up (default 1
).
Signature
declare const cursorPrevLine: (rows?: number) => AnsiDoc
Since v1.0.0
cursorRestorePosition
Restores the cursor position, encoding shift state and formatting attributes from the previous save, if any, otherwise resets these all to their defaults.
Signature
declare const cursorRestorePosition: AnsiDoc
Since v1.0.0
cursorSavePosition
Saves the cursor position, encoding shift state and formatting attributes.
Signature
declare const cursorSavePosition: AnsiDoc
Since v1.0.0
cursorShow
Shows the cursor.
Signature
declare const cursorShow: AnsiDoc
Since v1.0.0
cursorUp
Moves the cursor up by the specified number of lines
(default 1
) relative to the current cursor position.
If the cursor is already at the edge of the screen, this has no effect.
Signature
declare const cursorUp: (lines?: number) => AnsiDoc
Since v1.0.0
eraseDown
Clears from the current cursor position to the end of the screen.
The current cursor position does not change.
Signature
declare const eraseDown: AnsiDoc
Since v1.0.0
eraseEndLine
Clears from the current cursor position to the end of the current line.
The current cursor position does not change.
Signature
declare const eraseEndLine: AnsiDoc
Since v1.0.0
eraseLine
Clears the current line.
The current cursor position does not change.
Signature
declare const eraseLine: AnsiDoc
Since v1.0.0
eraseLines
Erase from the current cursor position up the specified amount of rows.
Signature
declare const eraseLines: (rows: number) => AnsiDoc
Since v1.0.0
eraseScreen
Clears the entire screen and move the cursor to the upper left.
Signature
declare const eraseScreen: AnsiDoc
Since v1.0.0
eraseStartLine
Clears from the current cursor position to the start of the current line.
The current cursor position does not change.
Signature
declare const eraseStartLine: AnsiDoc
Since v1.0.0
eraseUp
Clears from the current cursor position to the beginning of the screen.
The current cursor position does not change.
Signature
declare const eraseUp: AnsiDoc
Since v1.0.0
concatenation
cat
Signature
declare const cat: {
<B>(that: Doc<B>): <A>(self: Doc<A>) => Doc<B | A>
<A, B>(self: Doc<A>, that: Doc<B>): Doc<A | B>
}
Since v1.0.0
catWithLine
Signature
declare const catWithLine: {
<B>(that: Doc<B>): <A>(self: Doc<A>) => Doc<B | A>
<A, B>(self: Doc<A>, that: Doc<B>): Doc<A | B>
}
Since v1.0.0
catWithLineBreak
Signature
declare const catWithLineBreak: {
<B>(that: Doc<B>): <A>(self: Doc<A>) => Doc<B | A>
<A, B>(self: Doc<A>, that: Doc<B>): Doc<A | B>
}
Since v1.0.0
catWithSoftLine
Signature
declare const catWithSoftLine: {
<B>(that: Doc<B>): <A>(self: Doc<A>) => Doc<B | A>
<A, B>(self: Doc<A>, that: Doc<B>): Doc<A | B>
}
Since v1.0.0
catWithSoftLineBreak
Signature
declare const catWithSoftLineBreak: {
<B>(that: Doc<B>): <A>(self: Doc<A>) => Doc<B | A>
<A, B>(self: Doc<A>, that: Doc<B>): Doc<A | B>
}
Since v1.0.0
catWithSpace
Signature
declare const catWithSpace: {
<B>(that: Doc<B>): <A>(self: Doc<A>) => Doc<B | A>
<A, B>(self: Doc<A>, that: Doc<B>): Doc<A | B>
}
Since v1.0.0
cats
Signature
declare const cats: <A>(docs: Iterable<Doc<A>>) => Doc<A>
Since v1.0.0
concatWith
Signature
declare const concatWith: {
<A>(f: (left: Doc<A>, right: Doc<A>) => Doc<A>): (docs: Iterable<Doc<A>>) => Doc<A>
<A>(docs: Iterable<Doc<A>>, f: (left: Doc<A>, right: Doc<A>) => Doc<A>): Doc<A>
}
Since v1.0.0
hcat
Signature
declare const hcat: <A>(docs: Iterable<Doc<A>>) => Doc<A>
Since v1.0.0
vcat
Signature
declare const vcat: <A>(docs: Iterable<Doc<A>>) => Doc<A>
Since v1.0.0
constructors
beep
Play a beeping sound.
Signature
declare const beep: AnsiDoc
Since v1.0.0
char
Signature
declare const char: (char: string) => Doc<never>
Since v1.0.0
cursorMove
Move the cursor position the specified number of rows
and columns
relative to the current cursor position.
If the cursor is already at the edge of the screen in either direction, then additional movement will have no effect.
Signature
declare const cursorMove: (column: number, row?: number) => AnsiDoc
Since v1.0.0
cursorTo
Moves the cursor to the specified row
and column
.
Though the ANSI Control Sequence for Cursor Position is 1
-based, this method takes row and column values starting from 0
and adjusts them to 1
- based values.
Signature
declare const cursorTo: (column: number, row?: number) => AnsiDoc
Since v1.0.0
string
Signature
declare const string: (str: string) => Doc<never>
Since v1.0.0
text
Signature
declare const text: (text: string) => Doc<never>
Since v1.0.0
destructors
render
Signature
declare const render: {
(config: AnsiDoc.RenderConfig): (self: AnsiDoc) => string
(self: AnsiDoc, config: AnsiDoc.RenderConfig): string
}
Since v1.0.0
filling
fill
Signature
declare const fill: { (w: number): <A>(self: Doc<A>) => Doc<A>; <A>(self: Doc<A>, w: number): Doc<A> }
Since v1.0.0
fillBreak
Signature
declare const fillBreak: { (w: number): <A>(self: Doc<A>) => Doc<A>; <A>(self: Doc<A>, w: number): Doc<A> }
Since v1.0.0
fillCat
Signature
declare const fillCat: <A>(docs: Iterable<Doc<A>>) => Doc<A>
Since v1.0.0
fillSep
Signature
declare const fillSep: <A>(docs: Iterable<Doc<A>>) => Doc<A>
Since v1.0.0
flattening
changesUponFlattening
Signature
declare const changesUponFlattening: <A>(self: Doc<A>) => Flatten<Doc<A>>
Since v1.0.0
flatten
Signature
declare const flatten: <A>(self: Doc<A>) => Doc<A>
Since v1.0.0
instances
Invariant
Signature
declare const Invariant: Invariant<DocTypeLambda>
Since v1.0.0
matching
match
Signature
declare const match: {
<A, R>(patterns: {
readonly Fail: () => R
readonly Empty: () => R
readonly Char: (char: string) => R
readonly Text: (text: string) => R
readonly Line: () => R
readonly FlatAlt: (x: Doc<A>, y: Doc<A>) => R
readonly Cat: (x: Doc<A>, y: Doc<A>) => R
readonly Nest: (indent: number, doc: Doc<A>) => R
readonly Union: (x: Doc<A>, y: Doc<A>) => R
readonly Column: (react: (position: number) => Doc<A>) => R
readonly WithPageWidth: (react: (pageWidth: PageWidth) => Doc<A>) => R
readonly Nesting: (react: (level: number) => Doc<A>) => R
readonly Annotated: (annotation: A, doc: Doc<A>) => R
}): (self: Doc<A>) => R
<A, R>(
self: Doc<A>,
patterns: {
readonly Fail: () => R
readonly Empty: () => R
readonly Char: (char: string) => R
readonly Text: (text: string) => R
readonly Line: () => R
readonly FlatAlt: (x: Doc<A>, y: Doc<A>) => R
readonly Cat: (x: Doc<A>, y: Doc<A>) => R
readonly Nest: (indent: number, doc: Doc<A>) => R
readonly Union: (x: Doc<A>, y: Doc<A>) => R
readonly Column: (react: (position: number) => Doc<A>) => R
readonly WithPageWidth: (react: (pageWidth: PageWidth) => Doc<A>) => R
readonly Nesting: (react: (level: number) => Doc<A>) => R
readonly Annotated: (annotation: A, doc: Doc<A>) => R
}
): R
}
Since v1.0.0
model
AlreadyFlat
Signature
declare const AlreadyFlat: AlreadyFlat<A>
Since v1.0.0
Annotated
Signature
declare const Annotated: Annotated<A>
Since v1.0.0
AnsiDoc (type alias)
Signature
type AnsiDoc = Doc<Ansi>
Since v1.0.0
Cat
Signature
declare const Cat: Cat<A>
Since v1.0.0
Char
Signature
declare const Char: Char<A>
Since v1.0.0
Column
Signature
declare const Column: Column<A>
Since v1.0.0
Covariant
Signature
declare const Covariant: any
Since v1.0.0
Doc
Signature
declare const Doc: Doc<A>
Since v1.0.0
DocTypeId
Signature
declare const DocTypeId: unique symbol
Since v1.0.0
DocTypeLambda
Signature
declare const DocTypeLambda: DocTypeLambda
Since v1.0.0
Empty
Signature
declare const Empty: Empty<A>
Since v1.0.0
Fail
Signature
declare const Fail: Fail<A>
Since v1.0.0
FlatAlt
Signature
declare const FlatAlt: FlatAlt<A>
Since v1.0.0
Flatten
Signature
declare const Flatten: Flatten<A>
Since v1.0.0
Flattened
Signature
declare const Flattened: Flattened<A>
Since v1.0.0
Line
Signature
declare const Line: Line<A>
Since v1.0.0
Nest
Signature
declare const Nest: Nest<A>
Since v1.0.0
Nesting
Signature
declare const Nesting: Nesting<A>
Since v1.0.0
NeverFlat
Signature
declare const NeverFlat: NeverFlat<A>
Since v1.0.0
Text
Signature
declare const Text: Text<A>
Since v1.0.0
Union
Signature
declare const Union: Union<A>
Since v1.0.0
WithPageWidth
Signature
declare const WithPageWidth: WithPageWidth<A>
Since v1.0.0
primitives
backslash
Signature
declare const backslash: Doc<never>
Since v1.0.0
colon
Signature
declare const colon: Doc<never>
Since v1.0.0
comma
Signature
declare const comma: Doc<never>
Since v1.0.0
dot
Signature
declare const dot: Doc<never>
Since v1.0.0
dquote
Signature
declare const dquote: Doc<never>
Since v1.0.0
empty
Signature
declare const empty: Doc<never>
Since v1.0.0
equalSign
Signature
declare const equalSign: Doc<never>
Since v1.0.0
fail
Signature
declare const fail: Doc<never>
Since v1.0.0
hardLine
Signature
declare const hardLine: Doc<never>
Since v1.0.0
langle
Signature
declare const langle: Doc<never>
Since v1.0.0
lbrace
Signature
declare const lbrace: Doc<never>
Since v1.0.0
lbracket
Signature
declare const lbracket: Doc<never>
Since v1.0.0
line
Signature
declare const line: Doc<never>
Since v1.0.0
lineBreak
Signature
declare const lineBreak: Doc<never>
Since v1.0.0
lparen
Signature
declare const lparen: Doc<never>
Since v1.0.0
rangle
Signature
declare const rangle: Doc<never>
Since v1.0.0
rbrace
Signature
declare const rbrace: Doc<never>
Since v1.0.0
rbracket
Signature
declare const rbracket: Doc<never>
Since v1.0.0
rparen
Signature
declare const rparen: Doc<never>
Since v1.0.0
semi
Signature
declare const semi: Doc<never>
Since v1.0.0
slash
Signature
declare const slash: Doc<never>
Since v1.0.0
softLine
Signature
declare const softLine: Doc<never>
Since v1.0.0
softLineBreak
Signature
declare const softLineBreak: Doc<never>
Since v1.0.0
space
Signature
declare const space: Doc<never>
Since v1.0.0
squote
Signature
declare const squote: Doc<never>
Since v1.0.0
vbar
Signature
declare const vbar: Doc<never>
Since v1.0.0
reactive layouts
column
Signature
declare const column: <A>(react: (position: number) => Doc<A>) => Doc<A>
Since v1.0.0
nesting
Signature
declare const nesting: <A>(react: (level: number) => Doc<A>) => Doc<A>
Since v1.0.0
pageWidth
Signature
declare const pageWidth: <A>(react: (pageWidth: PageWidth) => Doc<A>) => Doc<A>
Since v1.0.0
width
Signature
declare const width: {
<A, B>(react: (width: number) => Doc<B>): (self: Doc<A>) => Doc<A | B>
<A, B>(self: Doc<A>, react: (width: number) => Doc<B>): Doc<A | B>
}
Since v1.0.0
refinements
isAnnotated
Signature
declare const isAnnotated: <A>(self: Doc<A>) => self is Annotated<A>
Since v1.0.0
isCat
Signature
declare const isCat: <A>(self: Doc<A>) => self is Cat<A>
Since v1.0.0
isChar
Signature
declare const isChar: <A>(self: Doc<A>) => self is Char<A>
Since v1.0.0
isColumn
Signature
declare const isColumn: <A>(self: Doc<A>) => self is Column<A>
Since v1.0.0
isDoc
Signature
declare const isDoc: (u: unknown) => u is Doc<unknown>
Since v1.0.0
isEmpty
Signature
declare const isEmpty: <A>(self: Doc<A>) => self is Empty<A>
Since v1.0.0
isFail
Signature
declare const isFail: <A>(self: Doc<A>) => self is Fail<A>
Since v1.0.0
isFlatAlt
Signature
declare const isFlatAlt: <A>(self: Doc<A>) => self is FlatAlt<A>
Since v1.0.0
isLine
Signature
declare const isLine: <A>(self: Doc<A>) => self is Line<A>
Since v1.0.0
isNest
Signature
declare const isNest: <A>(self: Doc<A>) => self is Nest<A>
Since v1.0.0
isNesting
Signature
declare const isNesting: <A>(self: Doc<A>) => self is Nesting<A>
Since v1.0.0
isText
Signature
declare const isText: <A>(self: Doc<A>) => self is Text<A>
Since v1.0.0
isUnion
Signature
declare const isUnion: <A>(self: Doc<A>) => self is Union<A>
Since v1.0.0
isWithPageWidth
Signature
declare const isWithPageWidth: <A>(self: Doc<A>) => self is WithPageWidth<A>
Since v1.0.0
separation
hsep
Signature
declare const hsep: <A>(docs: Iterable<Doc<A>>) => Doc<A>
Since v1.0.0
seps
Signature
declare const seps: <A>(docs: Iterable<Doc<A>>) => Doc<A>
Since v1.0.0
vsep
Signature
declare const vsep: <A>(docs: Iterable<Doc<A>>) => Doc<A>
Since v1.0.0
utilities
angleBracketed
Signature
declare const angleBracketed: <A>(self: Doc<A>) => Doc<A>
Since v1.0.0
curlyBraced
Signature
declare const curlyBraced: <A>(self: Doc<A>) => Doc<A>
Since v1.0.0
doubleQuoted
Signature
declare const doubleQuoted: <A>(self: Doc<A>) => Doc<A>
Since v1.0.0
parenthesized
Signature
declare const parenthesized: <A>(self: Doc<A>) => Doc<A>
Since v1.0.0
punctuate
Signature
declare const punctuate: {
<A, B>(punctuator: Doc<A>): (docs: Iterable<Doc<B>>) => ReadonlyArray<Doc<A | B>>
<A, B>(docs: Iterable<Doc<B>>, punctuator: Doc<A>): ReadonlyArray<Doc<A | B>>
}
Since v1.0.0
reflow
Signature
declare const reflow: (s: string, char?: string) => Doc<never>
Since v1.0.0
singleQuoted
Signature
declare const singleQuoted: <A>(self: Doc<A>) => Doc<A>
Since v1.0.0
spaces
Signature
declare const spaces: (n: number) => Doc<never>
Since v1.0.0
squareBracketed
Signature
declare const squareBracketed: <A>(self: Doc<A>) => Doc<A>
Since v1.0.0
surround
Signature
declare const surround: {
<A, B, C>(left: Doc<A>, right: Doc<B>): (self: Doc<C>) => Doc<A | B | C>
<A, B, C>(self: Doc<C>, left: Doc<A>, right: Doc<B>): Doc<A | B | C>
}
Since v1.0.0
textSpaces
Signature
declare const textSpaces: (n: number) => string
Since v1.0.0
words
Signature
declare const words: (s: string, char?: string) => ReadonlyArray<Doc<never>>
Since v1.0.0
utils
AnsiDoc (namespace)
Since v1.0.0
Compact (interface)
Signature
export interface Compact {
readonly style: "compact"
}
Since v1.0.0
Pretty (interface)
Signature
export interface Pretty {
readonly style: "pretty"
readonly options?: Partial<Omit<AvailablePerLine, "_tag">>
}
Since v1.0.0
Smart (interface)
Signature
export interface Smart {
readonly style: "smart"
readonly options?: Partial<Omit<AvailablePerLine, "_tag">>
}
Since v1.0.0
RenderConfig (type alias)
Signature
type RenderConfig = Compact | Pretty | Smart
Since v1.0.0