RoadmapShopEvents
Skip to main content

Home > @rushstack/terminal > TerminalTransform

TerminalTransform class

The abstract base class for TerminalWritable objects that receive an input, transform it somehow, and then write the output to another TerminalWritable.

Signature:

export declare abstract class TerminalTransform extends TerminalWritable 

Extends: TerminalWritable

Remarks

The TerminalTransform and SplitterTransform base classes formalize the idea of modeling data flow as a directed acyclic graph of reusable transforms, whose final outputs are TerminalWritable objects.

The design is based loosely on the WritableStream and TransformStream classes from the system Streams API, except that instead of asynchronous byte streams, the TerminalWritable system synchronously transmits human readable messages intended to be rendered on a text console or log file.

The main feature of the TerminalTransform class is its TerminalTransform.destination property, which tracks the next link in the graph.

Constructors

ConstructorModifiersDescription
(constructor)(options)Constructs a new instance of the TerminalTransform class

Properties

PropertyModifiersTypeDescription
destinationreadonlyTerminalWritableThe target TerminalWritable that the TerminalTransform will write its output to.
isOpenreadonlyboolean

This property is initially true when the object is constructed, and becomes false when close() is called.

(Inherited from TerminalWritable)

preventAutoclosereadonlyboolean(Inherited from TerminalWritable)
preventDestinationAutoclosereadonlybooleanPrevents the TerminalTransform.destination object from being closed automatically when the transform is closed.

Methods

MethodModifiersDescription
autocloseDestination()protectedThe default implementation of TerminalTransform.onClose() calls this method, which closes the TerminalTransform.destination if appropriate.
close()

Calling this method flushes any remaining outputs and permanently transitions the TerminalWritable to a "closed" state, where no further chunks can be written.

(Inherited from TerminalWritable)

onClose()protected
onWriteChunk(chunk)protected

Subclasses should implement this abstract method to process the chunk.

(Inherited from TerminalWritable)

writeChunk(chunk)

Upstream objects call this method to provide inputs to this object.

(Inherited from TerminalWritable)