Skip to content

Class FileInputStream ​

Source: fileStreams.ts

A stream that reads content from a VirtualFile and pushes it into the stream buffer.

Extends ​

Constructors ​

Constructor ​

new FileInputStream(file: VirtualFile): FileInputStream

Parameters ​

file ​

VirtualFile

Returns ​

FileInputStream

Overrides ​

Stream.constructor

Properties ​

DATA_EVENT ​

readonly static DATA_EVENT: "data" = "data"

Inherited from ​

Stream.DATA_EVENT


END_EVENT ​

readonly static END_EVENT: "end" = "end"

Inherited from ​

Stream.END_EVENT


SIGNAL_EVENT ​

readonly static SIGNAL_EVENT: "signal" = "signal"

Inherited from ​

Stream.SIGNAL_EVENT


ERROR_EVENT ​

readonly static ERROR_EVENT: "error" = "error"

Inherited from ​

Stream.ERROR_EVENT


INTERRUPTED ​

readonly static INTERRUPTED: "interrupted" = "interrupted"

Inherited from ​

Stream.INTERRUPTED


CLOSED ​

readonly static CLOSED: "closed" = "closed"

Inherited from ​

Stream.CLOSED

Methods ​

end() ​

end(): this

Closes the stream (EOF). Subsequent calls to write will be rejected.

Returns ​

this

Inherited from ​

Stream.end


signal() ​

signal(signal: StreamSignal): this

Emits a control signal. Standard termination signals will automatically close the stream.

Parameters ​

signal ​

StreamSignal

Returns ​

this

Inherited from ​

Stream.signal


write() ​

write(data: string): Promise<Result<void, StreamError>>

Broadcasts data to all listeners if the stream is open.

Parameters ​

data ​

string

Returns ​

Promise<Result<void, StreamError>>

Inherited from ​

Stream.write


read() ​

read(): Promise<Result<string | null, StreamError>>

Resolves with the next available chunk, or null if the stream is closed (EOF).

Returns ​

Promise<Result<string | null, StreamError>>

Inherited from ​

Stream.read


pipe() ​

pipe(destination: Stream<string>, propagateEnd?: boolean): Stream<string>

Forwards data, end events, and signals from this stream to another.

Parameters ​

destination ​

Stream<string>

The stream that will receive the forwarded data.

propagateEnd? ​

boolean = true

Returns ​

Stream<string>

The destination stream to allow for chainable piping.

Inherited from ​

Stream.pipe


wait() ​

Call Signature ​

wait(): Promise<void>

Returns a promise that resolves when the stream is stopped.

Returns ​

Promise<void>

Inherited from ​

Stream.wait

Call Signature ​

wait<U>(value: U): Promise<U>

Returns a promise that resolves when the stream is stopped.

Type Parameters ​
U ​

U

Parameters ​
value ​

U

Value to return when the promise resolves.

Returns ​

Promise<U>

Inherited from ​

Stream.wait


readLines() ​

static readLines(stream: InputStream): AsyncGenerator<Result<string, StreamError>>

Iterates over a readable string stream and yields each line.

Parameters ​

stream ​

InputStream

Returns ​

AsyncGenerator<Result<string, StreamError>>

Inherited from ​

Stream.readLines


on() ​

on<K>(event: K, listener: Listener<StreamEvents<string>, K>): Listener<StreamEvents<string>, K>

Starts listening to an event.

Type Parameters ​

K ​

K extends keyof StreamEvents<string>

Parameters ​

event ​

K

The event to listen to.

listener ​

Listener<StreamEvents<string>, K>

The function to call when the event is emitted.

Returns ​

Listener<StreamEvents<string>, K>

The listener.

Inherited from ​

Stream.on


once() ​

once<K>(event: K, listener: Listener<StreamEvents<string>, K>): Listener<StreamEvents<string>, K>

Registers an event listener that is automatically removed when called.

Type Parameters ​

K ​

K extends keyof StreamEvents<string>

Parameters ​

event ​

K

The event to listen to.

listener ​

Listener<StreamEvents<string>, K>

The function to call once the event is emitted.

Returns ​

Listener<StreamEvents<string>, K>

The wrapped listener.

Inherited from ​

Stream.once


off() ​

off<K>(event: K, listener: Listener<StreamEvents<string>, K>): void

Removes an event listener.

Type Parameters ​

K ​

K extends keyof StreamEvents<string>

Parameters ​

event ​

K

The event to remove the listener from.

listener ​

Listener<StreamEvents<string>, K>

The listener to remove.

Returns ​

void

Inherited from ​

Stream.off


emit() ​

emit<K>(event: K, ...args: StreamEvents<string>[K]): void

Emits an event to all its listeners.

Type Parameters ​

K ​

K extends keyof StreamEvents<string>

Parameters ​

event ​

K

The event to emit.

args ​

...StreamEvents<string>[K]

The arguments to pass to the listeners.

Returns ​

void

Inherited from ​

Stream.emit


emitAsync() ​

emitAsync<K>(event: K, ...args: StreamEvents<string>[K]): Promise<void>

Emits an event and waits for all listeners to resolve.

Type Parameters ​

K ​

K extends keyof StreamEvents<string>

Parameters ​

event ​

K

The event to emit.

args ​

...StreamEvents<string>[K]

The arguments to pass to the listeners.

Returns ​

Promise<void>

Inherited from ​

Stream.emitAsync

Built by Prozilla