ReadStream
Defined in: src/node/streams.ts:19
A ReadStream implementation that wraps an underlying global ReadableStream.
Extends
Section titled “Extends”Readable
Implements
Section titled “Implements”ReadStream
Constructors
Section titled “Constructors”Constructor
Section titled “Constructor”new ReadStream(
opts?,handleOrPromise):ReadStream
Defined in: src/node/streams.ts:26
Parameters
Section titled “Parameters”CreateReadStreamOptions = {}
handleOrPromise
Section titled “handleOrPromise”FileHandle | Promise<FileHandle>
Returns
Section titled “Returns”ReadStream
Overrides
Section titled “Overrides”Readable.constructor
Properties
Section titled “Properties”_events
Section titled “_events”_events:
Listeners
Defined in: node_modules/@zenfs/streams/dist/events.d.ts:28
Inherited from
Section titled “Inherited from”Readable._events
_eventsCount
Section titled “_eventsCount”_eventsCount:
number
Defined in: node_modules/@zenfs/streams/dist/events.d.ts:29
Inherited from
Section titled “Inherited from”Readable._eventsCount
_maxListeners?
Section titled “_maxListeners?”
optional_maxListeners?:number
Defined in: node_modules/@zenfs/streams/dist/events.d.ts:30
Inherited from
Section titled “Inherited from”Readable._maxListeners
_readableState
Section titled “_readableState”_readableState:
ReadableState
Defined in: node_modules/@zenfs/streams/dist/readable.d.ts:99
Inherited from
Section titled “Inherited from”Readable._readableState
_writableState?
Section titled “_writableState?”
optional_writableState?:WritableState
Defined in: node_modules/@zenfs/streams/dist/readable.d.ts:101
Present on a Duplex; undefined on a plain Readable.
Inherited from
Section titled “Inherited from”Readable._writableState
[kCapture]
Section titled “[kCapture]”
protected[kCapture]:boolean
Defined in: node_modules/@zenfs/streams/dist/events.d.ts:31
Inherited from
Section titled “Inherited from”Readable.[kCapture]
pending
Section titled “pending”pending:
boolean=true
Defined in: src/node/streams.ts:20
This property is true if the underlying file has not been opened yet,
i.e. before the 'ready' event is emitted.
v11.2.0, v10.16.0
Implementation of
Section titled “Implementation of”fs.ReadStream.pending
_fromList
Section titled “_fromList”
static_fromList: (n,state) =>any
Defined in: node_modules/@zenfs/streams/dist/readable.d.ts:163
Exposed for tests.
Takes n bytes (or one object) off the front of the buffer.
Parameters
Section titled “Parameters”number
ReadableState
Returns
Section titled “Returns”any
Inherited from
Section titled “Inherited from”Readable._fromList
captureRejections
Section titled “captureRejections”
staticcaptureRejections:boolean
Defined in: node_modules/@zenfs/streams/dist/events.d.ts:25
The default for the captureRejections option of newly created emitters.
Inherited from
Section titled “Inherited from”Readable.captureRejections
captureRejectionSymbol
Section titled “captureRejectionSymbol”
readonlystaticcaptureRejectionSymbol: typeofcaptureRejectionSymbol
Defined in: node_modules/@zenfs/streams/dist/events.d.ts:26
Inherited from
Section titled “Inherited from”Readable.captureRejectionSymbol
defaultMaxListeners
Section titled “defaultMaxListeners”
staticdefaultMaxListeners:number
Defined in: node_modules/@zenfs/streams/dist/events.d.ts:23
Inherited from
Section titled “Inherited from”Readable.defaultMaxListeners
errorMonitor
Section titled “errorMonitor”
readonlystaticerrorMonitor: typeoferrorMonitor
Defined in: node_modules/@zenfs/streams/dist/events.d.ts:27
Inherited from
Section titled “Inherited from”Readable.errorMonitor
ReadableState
Section titled “ReadableState”
readonlystaticReadableState: typeofReadableState
Defined in: node_modules/@zenfs/streams/dist/readable.d.ts:161
Inherited from
Section titled “Inherited from”Readable.ReadableState
Accessors
Section titled “Accessors”bytesRead
Section titled “bytesRead”Get Signature
Section titled “Get Signature”get bytesRead():
number
Defined in: src/node/streams.ts:77
The number of bytes that have been read so far.
v6.4.0
Returns
Section titled “Returns”number
Implementation of
Section titled “Implementation of”fs.ReadStream.bytesRead
closed
Section titled “closed”Get Signature
Section titled “Get Signature”get closed():
boolean
Defined in: node_modules/@zenfs/streams/dist/readable.d.ts:149
Is true after 'close' has been emitted.
v18.0.0
Returns
Section titled “Returns”boolean
Implementation of
Section titled “Implementation of”fs.ReadStream.closed
Inherited from
Section titled “Inherited from”Readable.closed
destroyed
Section titled “destroyed”Get Signature
Section titled “Get Signature”get destroyed():
boolean
Defined in: node_modules/@zenfs/streams/dist/readable.d.ts:150
Is true after readable.destroy() has been called.
v8.0.0
Returns
Section titled “Returns”boolean
Set Signature
Section titled “Set Signature”set destroyed(
value):void
Defined in: node_modules/@zenfs/streams/dist/readable.d.ts:151
Is true after readable.destroy() has been called.
v8.0.0
Parameters
Section titled “Parameters”boolean
Returns
Section titled “Returns”void
Implementation of
Section titled “Implementation of”fs.ReadStream.destroyed
Inherited from
Section titled “Inherited from”Readable.destroyed
errored
Section titled “errored”Get Signature
Section titled “Get Signature”get errored():
Error|null
Defined in: node_modules/@zenfs/streams/dist/readable.d.ts:148
Returns error if the stream has been destroyed with an error.
v18.0.0
Returns
Section titled “Returns”Error | null
Implementation of
Section titled “Implementation of”fs.ReadStream.errored
Inherited from
Section titled “Inherited from”Readable.errored
Get Signature
Section titled “Get Signature”get path():
string
Defined in: src/node/streams.ts:73
The path to the file the stream is reading from as specified in the first
argument to fs.createReadStream(). If path is passed as a string, thenreadStream.path will be a string. If path is passed as a Buffer, thenreadStream.path will be a
Buffer. If fd is specified, thenreadStream.path will be undefined.
v0.1.93
Returns
Section titled “Returns”string
Implementation of
Section titled “Implementation of”fs.ReadStream.path
readable
Section titled “readable”Get Signature
Section titled “Get Signature”get readable():
boolean
Defined in: node_modules/@zenfs/streams/dist/readable.d.ts:137
Is true if it is safe to call read, which means
the stream has not been destroyed or emitted 'error' or 'end'.
v11.4.0
Returns
Section titled “Returns”boolean
Set Signature
Section titled “Set Signature”set readable(
value):void
Defined in: node_modules/@zenfs/streams/dist/readable.d.ts:138
Is true if it is safe to call read, which means
the stream has not been destroyed or emitted 'error' or 'end'.
v11.4.0
Parameters
Section titled “Parameters”boolean
Returns
Section titled “Returns”void
Implementation of
Section titled “Implementation of”fs.ReadStream.readable
Inherited from
Section titled “Inherited from”Readable.readable
readableAborted
Section titled “readableAborted”Get Signature
Section titled “Get Signature”get readableAborted():
boolean
Defined in: node_modules/@zenfs/streams/dist/readable.d.ts:140
Returns whether the stream was destroyed or errored before emitting 'end'.
v16.8.0
Returns
Section titled “Returns”boolean
Implementation of
Section titled “Implementation of”fs.ReadStream.readableAborted
Inherited from
Section titled “Inherited from”Readable.readableAborted
readableBuffer
Section titled “readableBuffer”Get Signature
Section titled “Get Signature”get readableBuffer():
any[] |undefined
Defined in: node_modules/@zenfs/streams/dist/readable.d.ts:142
Returns
Section titled “Returns”any[] | undefined
Inherited from
Section titled “Inherited from”Readable.readableBuffer
readableDidRead
Section titled “readableDidRead”Get Signature
Section titled “Get Signature”get readableDidRead():
boolean
Defined in: node_modules/@zenfs/streams/dist/readable.d.ts:139
Returns whether 'data' has been emitted.
v16.7.0, v14.18.0
Returns
Section titled “Returns”boolean
Implementation of
Section titled “Implementation of”fs.ReadStream.readableDidRead
Inherited from
Section titled “Inherited from”Readable.readableDidRead
readableEncoding
Section titled “readableEncoding”Get Signature
Section titled “Get Signature”get readableEncoding():
BufferEncoding|null
Defined in: node_modules/@zenfs/streams/dist/readable.d.ts:147
Getter for the property encoding of a given Readable stream. The encoding property can be set using the setEncoding method.
v12.7.0
Returns
Section titled “Returns”BufferEncoding | null
Implementation of
Section titled “Implementation of”fs.ReadStream.readableEncoding
Inherited from
Section titled “Inherited from”Readable.readableEncoding
readableEnded
Section titled “readableEnded”Get Signature
Section titled “Get Signature”get readableEnded():
boolean
Defined in: node_modules/@zenfs/streams/dist/readable.d.ts:152
Becomes true when 'end' event is emitted.
v12.9.0
Returns
Section titled “Returns”boolean
Implementation of
Section titled “Implementation of”fs.ReadStream.readableEnded
Inherited from
Section titled “Inherited from”Readable.readableEnded
readableFlowing
Section titled “readableFlowing”Get Signature
Section titled “Get Signature”get readableFlowing():
boolean|null
Defined in: node_modules/@zenfs/streams/dist/readable.d.ts:143
This property reflects the current state of a Readable stream as described
in the Three states section.
v9.4.0
Returns
Section titled “Returns”boolean | null
Set Signature
Section titled “Set Signature”set readableFlowing(
value):void
Defined in: node_modules/@zenfs/streams/dist/readable.d.ts:144
This property reflects the current state of a Readable stream as described
in the Three states section.
v9.4.0
Parameters
Section titled “Parameters”boolean | null
Returns
Section titled “Returns”void
Implementation of
Section titled “Implementation of”fs.ReadStream.readableFlowing
Inherited from
Section titled “Inherited from”Readable.readableFlowing
readableHighWaterMark
Section titled “readableHighWaterMark”Get Signature
Section titled “Get Signature”get readableHighWaterMark():
number
Defined in: node_modules/@zenfs/streams/dist/readable.d.ts:141
Returns the value of highWaterMark passed when creating this Readable.
v9.3.0
Returns
Section titled “Returns”number
Implementation of
Section titled “Implementation of”fs.ReadStream.readableHighWaterMark
Inherited from
Section titled “Inherited from”Readable.readableHighWaterMark
readableLength
Section titled “readableLength”Get Signature
Section titled “Get Signature”get readableLength():
number
Defined in: node_modules/@zenfs/streams/dist/readable.d.ts:145
This property contains the number of bytes (or objects) in the queue
ready to be read. The value provides introspection data regarding
the status of the highWaterMark.
v9.4.0
Returns
Section titled “Returns”number
Implementation of
Section titled “Implementation of”fs.ReadStream.readableLength
Inherited from
Section titled “Inherited from”Readable.readableLength
readableObjectMode
Section titled “readableObjectMode”Get Signature
Section titled “Get Signature”get readableObjectMode():
boolean
Defined in: node_modules/@zenfs/streams/dist/readable.d.ts:146
Getter for the property objectMode of a given Readable stream.
v12.3.0
Returns
Section titled “Returns”boolean
Implementation of
Section titled “Implementation of”fs.ReadStream.readableObjectMode
Inherited from
Section titled “Inherited from”Readable.readableObjectMode
Methods
Section titled “Methods”_construct()?
Section titled “_construct()?”
optional_construct(callback):void
Defined in: node_modules/@zenfs/streams/dist/readable.d.ts:106
Parameters
Section titled “Parameters”callback
Section titled “callback”Callback
Returns
Section titled “Returns”void
Implementation of
Section titled “Implementation of”fs.ReadStream._construct
Inherited from
Section titled “Inherited from”Readable._construct
_destroy()
Section titled “_destroy()”_destroy(
error,callback):void
Defined in: node_modules/@zenfs/streams/dist/readable.d.ts:105
Parameters
Section titled “Parameters”Error | null
callback
Section titled “callback”Callback
Returns
Section titled “Returns”void
Implementation of
Section titled “Implementation of”fs.ReadStream._destroy
Inherited from
Section titled “Inherited from”Readable._destroy
_read()
Section titled “_read()”_read():
Promise<void>
Defined in: src/node/streams.ts:47
Returns
Section titled “Returns”Promise<void>
Implementation of
Section titled “Implementation of”fs.ReadStream._read
Overrides
Section titled “Overrides”Readable._read
_undestroy()
Section titled “_undestroy()”_undestroy():
void
Defined in: node_modules/@zenfs/streams/dist/readable.d.ts:104
Returns
Section titled “Returns”void
Inherited from
Section titled “Inherited from”Readable._undestroy
[asyncDispose]()
Section titled “[asyncDispose]()”[asyncDispose]():
Promise<void>
Defined in: node_modules/@zenfs/streams/dist/readable.d.ts:108
Returns
Section titled “Returns”Promise<void>
Implementation of
Section titled “Implementation of”fs.ReadStream.[asyncDispose]
Inherited from
Section titled “Inherited from”Readable.[asyncDispose]
[asyncIterator]()
Section titled “[asyncIterator]()”[asyncIterator]():
AsyncIterator<any>
Defined in: node_modules/@zenfs/streams/dist/readable.d.ts:135
Returns
Section titled “Returns”AsyncIterator<any>
Implementation of
Section titled “Implementation of”fs.ReadStream.[asyncIterator]
Inherited from
Section titled “Inherited from”Readable.[asyncIterator]
[captureRejectionSymbol]()
Section titled “[captureRejectionSymbol]()”[captureRejectionSymbol](
err):void
Defined in: node_modules/@zenfs/streams/dist/readable.d.ts:107
Parameters
Section titled “Parameters”Error
Returns
Section titled “Returns”void
Inherited from
Section titled “Inherited from”Readable.[captureRejectionSymbol]
[toAsyncStreamable]()
Section titled “[toAsyncStreamable]()”[toAsyncStreamable]():
AsyncGenerator<Uint8Array<ArrayBufferLike>[],any,any>
Defined in: node_modules/@zenfs/streams/dist/readable.d.ts:164
Returns
Section titled “Returns”AsyncGenerator<Uint8Array<ArrayBufferLike>[], any, any>
Implementation of
Section titled “Implementation of”fs.ReadStream.[toAsyncStreamable]
Inherited from
Section titled “Inherited from”Readable.[toAsyncStreamable]
addListener()
Section titled “addListener()”addListener(
ev,fn):this
Defined in: node_modules/@zenfs/streams/dist/readable.d.ts:126
Parameters
Section titled “Parameters”EventKey
Listener
Returns
Section titled “Returns”this
Implementation of
Section titled “Implementation of”fs.ReadStream.addListener
Inherited from
Section titled “Inherited from”Readable.addListener
close()
Section titled “close()”close(
callback?):void
Defined in: src/node/streams.ts:68
Like Node, the callback is invoked once the stream is closed.
Closing before the stream has finished reports ERR_STREAM_PREMATURE_CLOSE.
Parameters
Section titled “Parameters”callback?
Section titled “callback?”Callback<[void]> = ...
Returns
Section titled “Returns”void
Implementation of
Section titled “Implementation of”fs.ReadStream.close
compose()
Section titled “compose()”compose(
stream,options?):Duplex
Defined in: node_modules/@zenfs/streams/dist/readable.d.ts:199
Available once @zenfs/streams (or @zenfs/streams/compose) has been imported.
Parameters
Section titled “Parameters”stream
Section titled “stream”any
options?
Section titled “options?”signal?
Section titled “signal?”AbortSignal
Returns
Section titled “Returns”Duplex
Implementation of
Section titled “Implementation of”fs.ReadStream.compose
Inherited from
Section titled “Inherited from”Readable.compose
destroy()
Section titled “destroy()”destroy(
error?,callback?):this
Defined in: node_modules/@zenfs/streams/dist/readable.d.ts:103
Parameters
Section titled “Parameters”error?
Section titled “error?”Error | null
callback?
Section titled “callback?”Callback
Returns
Section titled “Returns”this
Implementation of
Section titled “Implementation of”fs.ReadStream.destroy
Inherited from
Section titled “Inherited from”Readable.destroy
drop()
Section titled “drop()”drop(
limit,options?):Readable
Defined in: node_modules/@zenfs/streams/dist/readable.d.ts:180
Parameters
Section titled “Parameters”number
options?
Section titled “options?”ReadableOperatorOptions
Returns
Section titled “Returns”Readable
Implementation of
Section titled “Implementation of”fs.ReadStream.drop
Inherited from
Section titled “Inherited from”Readable.drop
emit()
Section titled “emit()”emit(
type, …args):boolean
Defined in: node_modules/@zenfs/streams/dist/events.d.ts:35
Parameters
Section titled “Parameters”EventKey
…any[]
Returns
Section titled “Returns”boolean
Implementation of
Section titled “Implementation of”fs.ReadStream.emit
Inherited from
Section titled “Inherited from”Readable.emit
eventNames()
Section titled “eventNames()”eventNames():
EventKey[]
Defined in: node_modules/@zenfs/streams/dist/events.d.ts:47
Returns
Section titled “Returns”EventKey[]
Implementation of
Section titled “Implementation of”fs.ReadStream.eventNames
Inherited from
Section titled “Inherited from”Readable.eventNames
every()
Section titled “every()”every(
fn,options?):Promise<boolean>
Defined in: node_modules/@zenfs/streams/dist/readable.d.ts:182
Parameters
Section titled “Parameters”(value, options) => any
options?
Section titled “options?”ReadableOperatorOptions
Returns
Section titled “Returns”Promise<boolean>
Implementation of
Section titled “Implementation of”fs.ReadStream.every
Inherited from
Section titled “Inherited from”Readable.every
filter()
Section titled “filter()”filter(
fn,options?):Readable
Defined in: node_modules/@zenfs/streams/dist/readable.d.ts:174
Parameters
Section titled “Parameters”(value, options) => any
options?
Section titled “options?”ReadableOperatorOptions
Returns
Section titled “Returns”Readable
Implementation of
Section titled “Implementation of”fs.ReadStream.filter
Inherited from
Section titled “Inherited from”Readable.filter
find()
Section titled “find()”find(
fn,options?):Promise<any>
Defined in: node_modules/@zenfs/streams/dist/readable.d.ts:188
Parameters
Section titled “Parameters”(value, options) => any
options?
Section titled “options?”ReadableOperatorOptions
Returns
Section titled “Returns”Promise<any>
Implementation of
Section titled “Implementation of”fs.ReadStream.find
Inherited from
Section titled “Inherited from”Readable.find
flatMap()
Section titled “flatMap()”flatMap(
fn,options?):Readable
Defined in: node_modules/@zenfs/streams/dist/readable.d.ts:177
Parameters
Section titled “Parameters”(value, options) => any
options?
Section titled “options?”ReadableOperatorOptions
Returns
Section titled “Returns”Readable
Implementation of
Section titled “Implementation of”fs.ReadStream.flatMap
Inherited from
Section titled “Inherited from”Readable.flatMap
forEach()
Section titled “forEach()”forEach(
fn,options?):Promise<void>
Defined in: node_modules/@zenfs/streams/dist/readable.d.ts:191
Parameters
Section titled “Parameters”(value, options) => any
options?
Section titled “options?”ReadableOperatorOptions
Returns
Section titled “Returns”Promise<void>
Implementation of
Section titled “Implementation of”fs.ReadStream.forEach
Inherited from
Section titled “Inherited from”Readable.forEach
getMaxListeners()
Section titled “getMaxListeners()”getMaxListeners():
number
Defined in: node_modules/@zenfs/streams/dist/events.d.ts:34
Returns
Section titled “Returns”number
Implementation of
Section titled “Implementation of”fs.ReadStream.getMaxListeners
Inherited from
Section titled “Inherited from”Readable.getMaxListeners
isPaused()
Section titled “isPaused()”isPaused():
boolean
Defined in: node_modules/@zenfs/streams/dist/readable.d.ts:116
The readable.isPaused() method returns the current operating state of the Readable.
This is used primarily by the mechanism that underlies the readable.pipe() method.
In most typical cases, there will be no reason to use this method directly.
const readable = new stream.Readable();
readable.isPaused(); // === falsereadable.pause();readable.isPaused(); // === truereadable.resume();readable.isPaused(); // === falseReturns
Section titled “Returns”boolean
v0.11.14
Implementation of
Section titled “Implementation of”fs.ReadStream.isPaused
Inherited from
Section titled “Inherited from”Readable.isPaused
iterator()
Section titled “iterator()”iterator(
options?):AsyncIterator<any>
Defined in: node_modules/@zenfs/streams/dist/readable.d.ts:136
The iterator created by this method gives users the option to cancel the destruction
of the stream if the for await...of loop is exited by return, break, or throw,
or if the iterator should destroy the stream if the stream emitted an error during iteration.
Parameters
Section titled “Parameters”options?
Section titled “options?”ReadableIteratorOptions
Returns
Section titled “Returns”AsyncIterator<any>
v16.3.0
Implementation of
Section titled “Implementation of”fs.ReadStream.iterator
Inherited from
Section titled “Inherited from”Readable.iterator
listenerCount()
Section titled “listenerCount()”listenerCount(
type,listener?):number
Defined in: node_modules/@zenfs/streams/dist/events.d.ts:46
Parameters
Section titled “Parameters”EventKey
listener?
Section titled “listener?”Listener
Returns
Section titled “Returns”number
Implementation of
Section titled “Implementation of”fs.ReadStream.listenerCount
Inherited from
Section titled “Inherited from”Readable.listenerCount
listeners()
Section titled “listeners()”listeners(
type):Listener[]
Defined in: node_modules/@zenfs/streams/dist/events.d.ts:44
Parameters
Section titled “Parameters”EventKey
Returns
Section titled “Returns”Listener[]
Implementation of
Section titled “Implementation of”fs.ReadStream.listeners
Inherited from
Section titled “Inherited from”Readable.listeners
map(
fn,options?):Readable
Defined in: node_modules/@zenfs/streams/dist/readable.d.ts:171
Parameters
Section titled “Parameters”(value, options) => any
options?
Section titled “options?”ReadableOperatorOptions
Returns
Section titled “Returns”Readable
Implementation of
Section titled “Implementation of”fs.ReadStream.map
Inherited from
Section titled “Inherited from”Readable.map
off(
ev,fn):this
Defined in: node_modules/@zenfs/streams/dist/readable.d.ts:128
Parameters
Section titled “Parameters”EventKey
Listener
Returns
Section titled “Returns”this
Implementation of
Section titled “Implementation of”fs.ReadStream.off
Inherited from
Section titled “Inherited from”Readable.off
on(
ev,fn):this
Defined in: node_modules/@zenfs/streams/dist/readable.d.ts:125
Parameters
Section titled “Parameters”EventKey
Listener
Returns
Section titled “Returns”this
Implementation of
Section titled “Implementation of”fs.ReadStream.on
Inherited from
Section titled “Inherited from”Readable.on
once()
Section titled “once()”once(
type,listener):this
Defined in: node_modules/@zenfs/streams/dist/events.d.ts:39
Parameters
Section titled “Parameters”EventKey
listener
Section titled “listener”Listener
Returns
Section titled “Returns”this
Implementation of
Section titled “Implementation of”fs.ReadStream.once
Inherited from
Section titled “Inherited from”Readable.once
pause()
Section titled “pause()”pause():
this
Defined in: node_modules/@zenfs/streams/dist/readable.d.ts:132
The readable.pause() method will cause a stream in flowing mode to stop
emitting 'data' events, switching out of flowing mode. Any data that
becomes available will remain in the internal buffer.
const readable = getReadableStreamSomehow();readable.on('data', (chunk) => { console.log(`Received ${chunk.length} bytes of data.`); readable.pause(); console.log('There will be no additional data for 1 second.'); setTimeout(() => { console.log('Now data will start flowing again.'); readable.resume(); }, 1000);});The readable.pause() method has no effect if there is a 'readable' event listener.
Returns
Section titled “Returns”this
v0.9.4
Implementation of
Section titled “Implementation of”fs.ReadStream.pause
Inherited from
Section titled “Inherited from”Readable.pause
pipe()
Section titled “pipe()”pipe<
T>(dest,pipeOpts?):T
Defined in: node_modules/@zenfs/streams/dist/readable.d.ts:121
Type Parameters
Section titled “Type Parameters”T extends PipeDestination
Parameters
Section titled “Parameters”T
pipeOpts?
Section titled “pipeOpts?”boolean
Returns
Section titled “Returns”T
Implementation of
Section titled “Implementation of”fs.ReadStream.pipe
Inherited from
Section titled “Inherited from”Readable.pipe
prependListener()
Section titled “prependListener()”prependListener(
type,listener):this
Defined in: node_modules/@zenfs/streams/dist/events.d.ts:38
Parameters
Section titled “Parameters”EventKey
listener
Section titled “listener”Listener
Returns
Section titled “Returns”this
Implementation of
Section titled “Implementation of”fs.ReadStream.prependListener
Inherited from
Section titled “Inherited from”Readable.prependListener
prependOnceListener()
Section titled “prependOnceListener()”prependOnceListener(
type,listener):this
Defined in: node_modules/@zenfs/streams/dist/events.d.ts:40
Parameters
Section titled “Parameters”EventKey
listener
Section titled “listener”Listener
Returns
Section titled “Returns”this
Implementation of
Section titled “Implementation of”fs.ReadStream.prependOnceListener
Inherited from
Section titled “Inherited from”Readable.prependOnceListener
push()
Section titled “push()”push(
chunk,encoding?):boolean
Defined in: node_modules/@zenfs/streams/dist/readable.d.ts:113
Adds a chunk to the read buffer, or ends the stream when passed null.
Returns false once the high water mark is reached.
Parameters
Section titled “Parameters”any
encoding?
Section titled “encoding?”BufferEncoding
Returns
Section titled “Returns”boolean
Implementation of
Section titled “Implementation of”fs.ReadStream.push
Inherited from
Section titled “Inherited from”Readable.push
rawListeners()
Section titled “rawListeners()”rawListeners(
type):Listener[]
Defined in: node_modules/@zenfs/streams/dist/events.d.ts:45
Parameters
Section titled “Parameters”EventKey
Returns
Section titled “Returns”Listener[]
Implementation of
Section titled “Implementation of”fs.ReadStream.rawListeners
Inherited from
Section titled “Inherited from”Readable.rawListeners
read()
Section titled “read()”read(
n?):any
Defined in: node_modules/@zenfs/streams/dist/readable.d.ts:119
The readable.read() method reads data out of the internal buffer and
returns it. If no data is available to be read, null is returned. By default,
the data is returned as a Buffer object unless an encoding has been
specified using the readable.setEncoding() method or the stream is operating
in object mode.
The optional size argument specifies a specific number of bytes to read. If
size bytes are not available to be read, null will be returned unless the
stream has ended, in which case all of the data remaining in the internal buffer
will be returned.
If the size argument is not specified, all of the data contained in the
internal buffer will be returned.
The size argument must be less than or equal to 1 GiB.
The readable.read() method should only be called on Readable streams
operating in paused mode. In flowing mode, readable.read() is called
automatically until the internal buffer is fully drained.
const readable = getReadableStreamSomehow();
// 'readable' may be triggered multiple times as data is buffered inreadable.on('readable', () => { let chunk; console.log('Stream is readable (new data received in buffer)'); // Use a loop to make sure we read all currently available data while (null !== (chunk = readable.read())) { console.log(`Read ${chunk.length} bytes of data...`); }});
// 'end' will be triggered once when there is no more data availablereadable.on('end', () => { console.log('Reached end of stream.');});Each call to readable.read() returns a chunk of data, or null. The chunks
are not concatenated. A while loop is necessary to consume all data
currently in the buffer. When reading a large file .read() may return null,
having consumed all buffered content so far, but there is still more data to
come not yet buffered. In this case a new 'readable' event will be emitted
when there is more data in the buffer. Finally the 'end' event will be
emitted when there is no more data to come.
Therefore to read a file’s whole contents from a readable, it is necessary
to collect chunks across multiple 'readable' events:
const chunks = [];
readable.on('readable', () => { let chunk; while (null !== (chunk = readable.read())) { chunks.push(chunk); }});
readable.on('end', () => { const content = chunks.join('');});A Readable stream in object mode will always return a single item from
a call to readable.read(size), regardless of the value of the size argument.
If the readable.read() method returns a chunk of data, a 'data' event will
also be emitted.
Calling read after the 'end' event has
been emitted will return null. No runtime error will be raised.
Parameters
Section titled “Parameters”number | null
Returns
Section titled “Returns”any
v0.9.4
Implementation of
Section titled “Implementation of”fs.ReadStream.read
Inherited from
Section titled “Inherited from”Readable.read
reduce()
Section titled “reduce()”reduce(
reducer,initialValue?,options?):Promise<any>
Defined in: node_modules/@zenfs/streams/dist/readable.d.ts:195
Parameters
Section titled “Parameters”reducer
Section titled “reducer”(previous, value, options) => any
initialValue?
Section titled “initialValue?”any
options?
Section titled “options?”ReadableOperatorOptions
Returns
Section titled “Returns”Promise<any>
Implementation of
Section titled “Implementation of”fs.ReadStream.reduce
Inherited from
Section titled “Inherited from”Readable.reduce
removeAllListeners()
Section titled “removeAllListeners()”removeAllListeners(
ev?):this
Defined in: node_modules/@zenfs/streams/dist/readable.d.ts:129
Parameters
Section titled “Parameters”EventKey
Returns
Section titled “Returns”this
Implementation of
Section titled “Implementation of”fs.ReadStream.removeAllListeners
Inherited from
Section titled “Inherited from”Readable.removeAllListeners
removeListener()
Section titled “removeListener()”removeListener(
ev,fn):this
Defined in: node_modules/@zenfs/streams/dist/readable.d.ts:127
Parameters
Section titled “Parameters”EventKey
Listener
Returns
Section titled “Returns”this
Implementation of
Section titled “Implementation of”fs.ReadStream.removeListener
Inherited from
Section titled “Inherited from”Readable.removeListener
resume()
Section titled “resume()”resume():
this
Defined in: node_modules/@zenfs/streams/dist/readable.d.ts:131
Switches the stream into flowing mode.
Returns
Section titled “Returns”this
Implementation of
Section titled “Implementation of”fs.ReadStream.resume
Inherited from
Section titled “Inherited from”Readable.resume
setEncoding()
Section titled “setEncoding()”setEncoding(
encoding):this
Defined in: node_modules/@zenfs/streams/dist/readable.d.ts:118
Makes the stream emit strings in encoding rather than Buffers, without splitting characters.
Parameters
Section titled “Parameters”encoding
Section titled “encoding”BufferEncoding
Returns
Section titled “Returns”this
Implementation of
Section titled “Implementation of”fs.ReadStream.setEncoding
Inherited from
Section titled “Inherited from”Readable.setEncoding
setMaxListeners()
Section titled “setMaxListeners()”setMaxListeners(
n):this
Defined in: node_modules/@zenfs/streams/dist/events.d.ts:33
Parameters
Section titled “Parameters”number
Returns
Section titled “Returns”this
Implementation of
Section titled “Implementation of”fs.ReadStream.setMaxListeners
Inherited from
Section titled “Inherited from”Readable.setMaxListeners
some()
Section titled “some()”some(
fn,options?):Promise<boolean>
Defined in: node_modules/@zenfs/streams/dist/readable.d.ts:185
Parameters
Section titled “Parameters”(value, options) => any
options?
Section titled “options?”ReadableOperatorOptions
Returns
Section titled “Returns”Promise<boolean>
Implementation of
Section titled “Implementation of”fs.ReadStream.some
Inherited from
Section titled “Inherited from”Readable.some
take()
Section titled “take()”take(
limit,options?):Readable
Defined in: node_modules/@zenfs/streams/dist/readable.d.ts:181
Parameters
Section titled “Parameters”number
options?
Section titled “options?”ReadableOperatorOptions
Returns
Section titled “Returns”Readable
Implementation of
Section titled “Implementation of”fs.ReadStream.take
Inherited from
Section titled “Inherited from”Readable.take
toArray()
Section titled “toArray()”toArray(
options?):Promise<any[]>
Defined in: node_modules/@zenfs/streams/dist/readable.d.ts:194
Parameters
Section titled “Parameters”options?
Section titled “options?”ReadableOperatorOptions
Returns
Section titled “Returns”Promise<any[]>
Implementation of
Section titled “Implementation of”fs.ReadStream.toArray
Inherited from
Section titled “Inherited from”Readable.toArray
unpipe()
Section titled “unpipe()”unpipe(
dest?):this
Defined in: node_modules/@zenfs/streams/dist/readable.d.ts:124
The readable.unpipe() method detaches a Writable stream previously attached
using the pipe method.
If the destination is not specified, then all pipes are detached.
If the destination is specified, but no pipe is set up for it, then
the method does nothing.
import fs from 'node:fs';const readable = getReadableStreamSomehow();const writable = fs.createWriteStream('file.txt');// All the data from readable goes into 'file.txt',// but only for the first second.readable.pipe(writable);setTimeout(() => { console.log('Stop writing to file.txt.'); readable.unpipe(writable); console.log('Manually close the file stream.'); writable.end();}, 1000);Parameters
Section titled “Parameters”PipeDestination
Returns
Section titled “Returns”this
v0.9.4
Implementation of
Section titled “Implementation of”fs.ReadStream.unpipe
Inherited from
Section titled “Inherited from”Readable.unpipe
unshift()
Section titled “unshift()”unshift(
chunk,encoding?):boolean
Defined in: node_modules/@zenfs/streams/dist/readable.d.ts:115
Returns a chunk to the front of the read buffer. Should only ever be a chunk that came out of read().
Parameters
Section titled “Parameters”any
encoding?
Section titled “encoding?”BufferEncoding
Returns
Section titled “Returns”boolean
Implementation of
Section titled “Implementation of”fs.ReadStream.unshift
Inherited from
Section titled “Inherited from”Readable.unshift
wrap()
Section titled “wrap()”wrap(
oldStream):this
Defined in: src/node/streams.ts:81
Uses an old-style (pre-streams2) stream as this stream’s data source.
Parameters
Section titled “Parameters”oldStream
Section titled “oldStream”ReadableStream
Returns
Section titled “Returns”this
Implementation of
Section titled “Implementation of”fs.ReadStream.wrap
Overrides
Section titled “Overrides”Readable.wrap
from()
Section titled “from()”
staticfrom(iterable,options?):Readable
Defined in: node_modules/@zenfs/streams/dist/readable.d.ts:154
Builds a Readable from an iterable, async iterable, string or Buffer.
Parameters
Section titled “Parameters”iterable
Section titled “iterable”string | Buffer<ArrayBufferLike> | Iterable<unknown, any, any> | AsyncIterable<unknown, any, any>
options?
Section titled “options?”ReadableOptions<Readable>
Returns
Section titled “Returns”Readable
Inherited from
Section titled “Inherited from”Readable.from
fromWeb()
Section titled “fromWeb()”
staticfromWeb(readableStream,options?):Readable
Defined in: node_modules/@zenfs/streams/dist/readable.d.ts:158
Wraps a WHATWG ReadableStream.
Parameters
Section titled “Parameters”readableStream
Section titled “readableStream”ReadableStream
options?
Section titled “options?”ReadableOptions<Readable>
Returns
Section titled “Returns”Readable
Inherited from
Section titled “Inherited from”Readable.fromWeb
toWeb()
Section titled “toWeb()”
statictoWeb(streamReadable,options?):ReadableStream
Defined in: node_modules/@zenfs/streams/dist/readable.d.ts:160
Exposes this stream as a WHATWG ReadableStream.
Parameters
Section titled “Parameters”streamReadable
Section titled “streamReadable”Readable
options?
Section titled “options?”ReadableToWebOptions
Returns
Section titled “Returns”ReadableStream
Inherited from
Section titled “Inherited from”Readable.toWeb
wrap()
Section titled “wrap()”
staticwrap(src,options?):Readable
Defined in: node_modules/@zenfs/streams/dist/readable.d.ts:156
Wraps an old-style stream, or any object with a compatible data/end event surface.
Parameters
Section titled “Parameters”any
options?
Section titled “options?”ReadableOptions<Readable>
Returns
Section titled “Returns”Readable
Inherited from
Section titled “Inherited from”Readable.wrap