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
Returns
Overrides
Properties
DATA_EVENT
readonlystaticDATA_EVENT:"data"="data"
Inherited from
END_EVENT
readonlystaticEND_EVENT:"end"="end"
Inherited from
SIGNAL_EVENT
readonlystaticSIGNAL_EVENT:"signal"="signal"
Inherited from
ERROR_EVENT
readonlystaticERROR_EVENT:"error"="error"
Inherited from
INTERRUPTED
readonlystaticINTERRUPTED:"interrupted"="interrupted"
Inherited from
CLOSED
readonlystaticCLOSED:"closed"="closed"
Inherited from
Methods
end()
end():
this
Closes the stream (EOF). Subsequent calls to write will be rejected.
Returns
this
Inherited from
signal()
signal(
signal:StreamSignal):this
Emits a control signal. Standard termination signals will automatically close the stream.
Parameters
signal
Returns
this
Inherited from
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
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
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
wait()
Call Signature
wait():
Promise<void>
Returns a promise that resolves when the stream is stopped.
Returns
Promise<void>
Inherited from
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
readLines()
staticreadLines(stream:InputStream):AsyncGenerator<Result<string,StreamError>>
Iterates over a readable string stream and yields each line.
Parameters
stream
Returns
AsyncGenerator<Result<string, StreamError>>
Inherited from
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
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
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
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
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>