Duplex streams are streams that implement both the Readable
and Writable
interfaces.
See also:
Constructor
Variables
Is true
if it is safe to call writable.write()
.
See also:
Is true
after writable.end()
has been called. This property
does not indicate whether the data has been flushed, for this use
writable.writableFinished
instead.
See also:
Is set to true
immediately before the 'finish' event is emitted.
See also:
This property contains the number of bytes (or objects) in the queue ready to be written.
The value provides introspection data regarding the status of the highWaterMark
.
See also:
Getter for the property objectMode
of a given Writable
stream.
See also:
Return the value of highWaterMark
passed when constructing this Writable
.
See also:
Methods
The writable.cork()
method forces all written data to be buffered in memory.
The buffered data will be flushed when either the stream.uncork()
or stream.end()
methods are called.
See also:
Destroy the stream.
Optionally emit an 'error'
event, and emit a 'close'
event unless emitClose
is set in false
.
See also:
Calling the writable.end()
method signals that no more data will be written to the Writable.
The optional chunk
and encoding
arguments allow one final additional chunk of data to be written immediately before closing the stream.
If provided, the optional callback
function is attached as a listener for the 'finish' event.
See also:
The writable.setDefaultEncoding()
method sets the default encoding
for a Writable stream.
See also:
The writable.uncork()
method flushes all data buffered since stream.cork()
was called.
See also:
The writable.write()
method writes some data to the stream, and calls the supplied callback
once the data has been fully handled.
If an error occurs, the callback
may or may not be called with the error as its first argument.
To reliably detect write errors, add a listener for the 'error'
event.
See also:
Inherited Variables
Is true
after readable.destroy()
has been called.
See also:
Terminal read streams (i.e. process.stdin) have this property set to true.
It is false for any other read streams.
See also:
Is true
if it is safe to call readable.read()
.
See also:
Getter for the property encoding
of a given Readable
stream.
The encoding
property can be set using the readable.setEncoding()
method.
See also:
Becomes true
when 'end'
event is emitted.
See also:
Returns the value of highWaterMark
passed when constructing this Readable
.
See also:
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
.
See also:
Getter for the property objectMode
of a given Readable
stream.
See also:
Inherited Methods
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.
See also:
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.
See also:
pipe<T>(destination:T, ?options:{end:Null<Bool>}):T
The readable.pipe()
method attaches a Writable
stream to the readable
,
causing it to switch automatically into flowing mode and push all of its data to the attached Writable
.
The flow of data will be automatically managed so that the destination Writable
stream
is not overwhelmed by a faster Readable
stream.
See also:
The readable.read()
method pulls some data out of the internal buffer and returns it.
If no data available to be read, null
is returned. By default,
the data will be returned as a Buffer
object unless an encoding has been specified using
the readable.setEncoding()
method or the stream is operating in object mode.
See also:
The readable.resume()
method causes an explicitly paused Readable
stream to resume emitting 'data'
events,
switching the stream into flowing mode.
See also:
The readable.setEncoding()
method sets the character encoding for data read from the Readable
stream.
See also:
The readable.unpipe()
method detaches a Writable
stream previously attached using the stream.pipe()
method.
See also:
Passing chunk
as null
signals the end of the stream (EOF), after which no more data can be written.
See also:
Prior to Node.js 0.10, streams did not implement the entire stream
module API as it is currently defined.
(See Compatibility for more information.)
See also:
addListener<T>(eventName:Event<T>, listener:T):TSelf
Alias for emitter.on(eventName, listener)
.
See also:
Synchronously calls each of the listeners registered for the event named
eventName
, in the order they were registered, passing the supplied arguments
to each.
See also:
Returns an array listing the events for which the emitter has registered
listeners. The values in the array will be strings or Symbol
s.
See also:
Returns the number of listeners listening to the event named eventName
.
See also:
Returns a copy of the array of listeners for the event named eventName
.
See also:
off<T>(eventName:Event<T>, listener:T):TSelf
Alias for emitter.removeListener()
.
See also:
on<T>(eventName:Event<T>, listener:T):TSelf
Adds the listener
function to the end of the listeners array for the
event named eventName
. No checks are made to see if the listener
has
already been added. Multiple calls passing the same combination of eventName
and listener
will result in the listener
being added, and called, multiple
times.
See also:
once<T>(eventName:Event<T>, listener:T):TSelf
Adds a one-time listener
function for the event named eventName
. The
next time eventName
is triggered, this listener is removed and then invoked.
See also:
Adds the listener
function to the beginning of the listeners array for the
event named eventName
. No checks are made to see if the listener
has
already been added. Multiple calls passing the same combination of eventName
and listener
will result in the listener
being added, and called, multiple
times.
See also:
Adds a one-time listener
function for the event named eventName
to the
beginning of the listeners array. The next time eventName
is triggered, this
listener is removed, and then invoked.
See also:
Returns a copy of the array of listeners for the event named eventName
,
including any wrappers (such as those created by .once()
).
See also:
Removes all listeners, or those of the specified eventName
.
See also:
Removes the specified listener
from the listener array for the event named
eventName
.
See also:
By default EventEmitter
s will print a warning if more than 10
listeners are
added for a particular event. This is a useful default that helps finding
memory leaks. Obviously, not all events should be limited to just 10 listeners.
The emitter.setMaxListeners()
method allows the limit to be modified for this
specific EventEmitter
instance. The value can be set to Infinity
(or 0
)
to indicate an unlimited number of listeners.
See also: