Class: NoOpTransport
Extends
TransportStream
Constructors
new NoOpTransport()
new NoOpTransport(
opts
?):NoOpTransport
Parameters
• opts?: any
Returns
Overrides
TransportStream.constructor
Properties
closed
readonly
closed:boolean
Is true after 'close' has been emitted.
Since
v8.0.0
Inherited from
TransportStream.closed
destroyed
destroyed:
boolean
Is true
after writable.destroy()
has been called.
Since
v8.0.0
Inherited from
TransportStream.destroyed
errored
readonly
errored:Error
Returns error if the stream has been destroyed with an error.
Since
v18.0.0
Inherited from
TransportStream.errored
format?
optional
format:Format
Inherited from
TransportStream.format
handleExceptions?
optional
handleExceptions:boolean
Inherited from
TransportStream.handleExceptions
handleRejections?
optional
handleRejections:boolean
Inherited from
TransportStream.handleRejections
level?
optional
level:string
Inherited from
TransportStream.level
silent?
optional
silent:boolean
Inherited from
TransportStream.silent
writable
readonly
writable:boolean
Is true
if it is safe to call writable.write()
, which means
the stream has not been destroyed, errored or ended.
Since
v11.4.0
Inherited from
TransportStream.writable
writableCorked
readonly
writableCorked:number
Number of times writable.uncork()
needs to be
called in order to fully uncork the stream.
Since
v13.2.0, v12.16.0
Inherited from
TransportStream.writableCorked
writableEnded
readonly
writableEnded:boolean
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.
Since
v12.9.0
Inherited from
TransportStream.writableEnded
writableFinished
readonly
writableFinished:boolean
Is set to true
immediately before the 'finish'
event is emitted.
Since
v12.6.0
Inherited from
TransportStream.writableFinished
writableHighWaterMark
readonly
writableHighWaterMark:number
Return the value of highWaterMark
passed when creating this Writable
.
Since
v9.3.0
Inherited from
TransportStream.writableHighWaterMark
writableLength
readonly
writableLength:number
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
.
Since
v9.4.0
Inherited from
TransportStream.writableLength
writableNeedDrain
readonly
writableNeedDrain:boolean
Is true
if the stream's buffer has been full and stream will emit 'drain'.
Since
v15.2.0, v14.17.0
Inherited from
TransportStream.writableNeedDrain
writableObjectMode
readonly
writableObjectMode:boolean
Getter for the property objectMode
of a given Writable
stream.
Since
v12.3.0
Inherited from
TransportStream.writableObjectMode
captureRejectionSymbol
readonly
static
captureRejectionSymbol: typeofcaptureRejectionSymbol
Inherited from
TransportStream.captureRejectionSymbol
captureRejections
static
captureRejections:boolean
Sets or gets the default captureRejection value for all emitters.
Inherited from
TransportStream.captureRejections
defaultMaxListeners
static
defaultMaxListeners:number
Inherited from
TransportStream.defaultMaxListeners
errorMonitor
readonly
static
errorMonitor: typeoferrorMonitor
This symbol shall be used to install a listener for only monitoring 'error'
events. Listeners installed using this symbol are called before the regular
'error'
listeners are called.
Installing a listener using this symbol does not change the behavior once an
'error'
event is emitted, therefore the process will still crash if no
regular 'error'
listener is installed.
Inherited from
TransportStream.errorMonitor
Methods
_construct()?
optional
_construct(callback
):void
Parameters
• callback
Returns
void
Inherited from
TransportStream._construct
_destroy()
_destroy(
error
,callback
):void
Parameters
• error: Error
• callback
Returns
void
Inherited from
TransportStream._destroy
_final()
_final(
callback
):void
Parameters
• callback
Returns
void
Inherited from
TransportStream._final
_write()
_write(
chunk
,encoding
,callback
):void
Parameters
• chunk: any
• encoding: BufferEncoding
• callback
Returns
void
Inherited from
TransportStream._write
_writev()?
optional
_writev(chunks
,callback
):void
Parameters
• chunks: object
[]
• callback
Returns
void
Inherited from
TransportStream._writev
addListener()
addListener(event, listener)
addListener(
event
,listener
):this
Event emitter The defined events on documents including:
- close
- drain
- error
- finish
- pipe
- unpipe
Parameters
• event: "close"
• listener
Returns
this
Inherited from
TransportStream.addListener
addListener(event, listener)
addListener(
event
,listener
):this
Alias for emitter.on(eventName, listener)
.
Parameters
• event: "drain"
• listener
Returns
this
Since
v0.1.26
Inherited from
TransportStream.addListener
addListener(event, listener)
addListener(
event
,listener
):this
Alias for emitter.on(eventName, listener)
.
Parameters
• event: "error"
• listener
Returns
this
Since
v0.1.26
Inherited from
TransportStream.addListener
addListener(event, listener)
addListener(
event
,listener
):this
Alias for emitter.on(eventName, listener)
.
Parameters
• event: "finish"
• listener
Returns
this
Since
v0.1.26
Inherited from
TransportStream.addListener
addListener(event, listener)
addListener(
event
,listener
):this
Alias for emitter.on(eventName, listener)
.
Parameters
• event: "pipe"
• listener
Returns
this
Since
v0.1.26
Inherited from
TransportStream.addListener
addListener(event, listener)
addListener(
event
,listener
):this
Alias for emitter.on(eventName, listener)
.
Parameters
• event: "unpipe"
• listener
Returns
this
Since
v0.1.26
Inherited from
TransportStream.addListener
addListener(event, listener)
addListener(
event
,listener
):this
Alias for emitter.on(eventName, listener)
.
Parameters
• event: string
| symbol
• listener
Returns
this
Since
v0.1.26
Inherited from
TransportStream.addListener
close()?
optional
close():void
Returns
void
Inherited from
TransportStream.close
cork()
cork():
void
The writable.cork()
method forces all written data to be buffered in memory.
The buffered data will be flushed when either the uncork or end methods are called.
The primary intent of writable.cork()
is to accommodate a situation in which
several small chunks are written to the stream in rapid succession. Instead of
immediately forwarding them to the underlying destination, writable.cork()
buffers all the chunks until writable.uncork()
is called, which will pass them
all to writable._writev()
, if present. This prevents a head-of-line blocking
situation where data is being buffered while waiting for the first small chunk
to be processed. However, use of writable.cork()
without implementingwritable._writev()
may have an adverse effect on throughput.
See also: writable.uncork()
, writable._writev()
.
Returns
void
Since
v0.11.2
Inherited from
TransportStream.cork
destroy()
destroy(
error
?):this
Destroy the stream. Optionally emit an 'error'
event, and emit a 'close'
event (unless emitClose
is set to false
). After this call, the writable
stream has ended and subsequent calls to write()
or end()
will result in
an ERR_STREAM_DESTROYED
error.
This is a destructive and immediate way to destroy a stream. Previous calls towrite()
may not have drained, and may trigger an ERR_STREAM_DESTROYED
error.
Use end()
instead of destroy if data should flush before close, or wait for
the 'drain'
event before destroying the stream.
Once destroy()
has been called any further calls will be a no-op and no
further errors except from _destroy()
may be emitted as 'error'
.
Implementors should not override this method,
but instead implement writable._destroy()
.
Parameters
• error?: Error
Optional, an error to emit with 'error'
event.
Returns
this
Since
v8.0.0
Inherited from
TransportStream.destroy
emit()
emit(event)
emit(
event
):boolean
Synchronously calls each of the listeners registered for the event namedeventName
, in the order they were registered, passing the supplied arguments
to each.
Returns true
if the event had listeners, false
otherwise.
const EventEmitter = require('events');
const myEmitter = new EventEmitter();
// First listener
myEmitter.on('event', function firstListener() {
console.log('Helloooo! first listener');
});
// Second listener
myEmitter.on('event', function secondListener(arg1, arg2) {
console.log(`event with parameters ${arg1}, ${arg2} in second listener`);
});
// Third listener
myEmitter.on('event', function thirdListener(...args) {
const parameters = args.join(', ');
console.log(`event with parameters ${parameters} in third listener`);
});
console.log(myEmitter.listeners('event'));
myEmitter.emit('event', 1, 2, 3, 4, 5);
// Prints:
// [
// [Function: firstListener],
// [Function: secondListener],
// [Function: thirdListener]
// ]
// Helloooo! first listener
// event with parameters 1, 2 in second listener
// event with parameters 1, 2, 3, 4, 5 in third listener
Parameters
• event: "close"
Returns
boolean
Since
v0.1.26
Inherited from
TransportStream.emit
emit(event)
emit(
event
):boolean
Synchronously calls each of the listeners registered for the event namedeventName
, in the order they were registered, passing the supplied arguments
to each.
Returns true
if the event had listeners, false
otherwise.
const EventEmitter = require('events');
const myEmitter = new EventEmitter();
// First listener
myEmitter.on('event', function firstListener() {
console.log('Helloooo! first listener');
});
// Second listener
myEmitter.on('event', function secondListener(arg1, arg2) {
console.log(`event with parameters ${arg1}, ${arg2} in second listener`);
});
// Third listener
myEmitter.on('event', function thirdListener(...args) {
const parameters = args.join(', ');
console.log(`event with parameters ${parameters} in third listener`);
});
console.log(myEmitter.listeners('event'));
myEmitter.emit('event', 1, 2, 3, 4, 5);
// Prints:
// [
// [Function: firstListener],
// [Function: secondListener],
// [Function: thirdListener]
// ]
// Helloooo! first listener
// event with parameters 1, 2 in second listener
// event with parameters 1, 2, 3, 4, 5 in third listener