class internal.Duplex
implements WritableBase
extends ReadableBase
Duplex streams are streams that implement both the Readable
and Writable
interfaces.
Examples of Duplex
streams include:
TCP sockets
zlib streams
crypto streams
Constructors Jump to heading
new
Jump to headingDuplex(opts?: DuplexOptions)
Properties Jump to heading
Jump to headingallowHalfOpen: boolean
If false
then the stream will automatically end the writable side when the
readable side ends. Set initially by the allowHalfOpen
constructor option,
which defaults to true
.
This can be changed manually to change the half-open behavior of an existing
Duplex
stream instance, but must be changed before the 'end'
event is emitted.
readonly
Jump to headingclosed: boolean
readonly
Jump to headingerrored: Error | null
readonly
Jump to headingwritable: boolean
readonly
Jump to headingwritableCorked: number
readonly
Jump to headingwritableEnded: boolean
readonly
Jump to headingwritableFinished: boolean
readonly
Jump to headingwritableHighWaterMark: number
readonly
Jump to headingwritableLength: number
readonly
Jump to headingwritableNeedDrain: boolean
readonly
Jump to headingwritableObjectMode: boolean
Methods Jump to heading
Jump to heading_destroy(error: Error | null,callback: (error?: Error | null) => void,): void
Jump to heading_final(callback: (error?: Error | null) => void): void
Jump to heading_write(chunk: any,encoding: BufferEncoding,callback: (error?: Error | null) => void,): void
optional
Jump to heading_writev(chunks: Array<{ chunk: any; encoding: BufferEncoding; }>,callback: (error?: Error | null) => void,): void
Jump to headingaddListener(event: "close",listener: () => void,): this
Event emitter The defined events on documents including:
- close
- data
- drain
- end
- error
- finish
- pause
- pipe
- readable
- resume
- unpipe
Jump to headingaddListener(event: "data",listener: (chunk: any) => void,): this
Jump to headingaddListener(event: "drain",listener: () => void,): this
Jump to headingaddListener(event: "end",listener: () => void,): this
Jump to headingaddListener(event: "error",listener: (err: Error) => void,): this
Jump to headingaddListener(event: "finish",listener: () => void,): this
Jump to headingaddListener(event: "pause",listener: () => void,): this
Jump to headingaddListener(event: "pipe",listener: (src: Readable) => void,): this
Jump to headingaddListener(event: "readable",listener: () => void,): this
Jump to headingaddListener(event: "resume",listener: () => void,): this
Jump to headingaddListener(event: "unpipe",listener: (src: Readable) => void,): this
Jump to headingaddListener(event: string | symbol,listener: (...args: any[]) => void,): this
Jump to headingcork(): void
Jump to headingemit(event: "close"): boolean
Jump to headingemit(event: "data",chunk: any,): boolean
Jump to headingemit(event: "drain"): boolean
Jump to headingemit(event: "end"): boolean
Jump to headingemit(event: "error",err: Error,): boolean
Jump to headingemit(event: "finish"): boolean
Jump to headingemit(event: "pause"): boolean
Jump to headingemit(event: "pipe",src: Readable,): boolean
Jump to headingemit(event: "readable"): boolean
Jump to headingemit(event: "resume"): boolean
Jump to headingemit(event: "unpipe",src: Readable,): boolean
Jump to headingemit(event: string | symbol,...args: any[],): boolean
Jump to headingend(cb?: () => void): this
Jump to headingend(chunk: any,cb?: () => void,): this
Jump to headingend(chunk: any,encoding?: BufferEncoding,cb?: () => void,): this
Jump to headingon(event: "close",listener: () => void,): this
Jump to headingon(event: "data",listener: (chunk: any) => void,): this
Jump to headingon(event: "drain",listener: () => void,): this
Jump to headingon(event: "end",listener: () => void,): this
Jump to headingon(event: "error",listener: (err: Error) => void,): this
Jump to headingon(event: "finish",listener: () => void,): this
Jump to headingon(event: "pause",listener: () => void,): this
Jump to headingon(event: "pipe",listener: (src: Readable) => void,): this
Jump to headingon(event: "readable",listener: () => void,): this
Jump to headingon(event: "resume",listener: () => void,): this
Jump to headingon(event: "unpipe",listener: (src: Readable) => void,): this
Jump to headingon(event: string | symbol,listener: (...args: any[]) => void,): this
Jump to headingonce(event: "close",listener: () => void,): this
Jump to headingonce(event: "data",listener: (chunk: any) => void,): this
Jump to headingonce(event: "drain",listener: () => void,): this
Jump to headingonce(event: "end",listener: () => void,): this
Jump to headingonce(event: "error",listener: (err: Error) => void,): this
Jump to headingonce(event: "finish",listener: () => void,): this
Jump to headingonce(event: "pause",listener: () => void,): this
Jump to headingonce(event: "pipe",listener: (src: Readable) => void,): this
Jump to headingonce(event: "readable",listener: () => void,): this
Jump to headingonce(event: "resume",listener: () => void,): this
Jump to headingonce(event: "unpipe",listener: (src: Readable) => void,): this
Jump to headingonce(event: string | symbol,listener: (...args: any[]) => void,): this
Jump to headingprependListener(event: "close",listener: () => void,): this
Jump to headingprependListener(event: "data",listener: (chunk: any) => void,): this
Jump to headingprependListener(event: "drain",listener: () => void,): this
Jump to headingprependListener(event: "end",listener: () => void,): this
Jump to headingprependListener(event: "error",listener: (err: Error) => void,): this
Jump to headingprependListener(event: "finish",listener: () => void,): this
Jump to headingprependListener(event: "pause",listener: () => void,): this
Jump to headingprependListener(event: "pipe",listener: (src: Readable) => void,): this
Jump to headingprependListener(event: "readable",listener: () => void,): this
Jump to headingprependListener(event: "resume",listener: () => void,): this
Jump to headingprependListener(event: "unpipe",listener: (src: Readable) => void,): this
Jump to headingprependListener(event: string | symbol,listener: (...args: any[]) => void,): this
Jump to headingprependOnceListener(event: "close",listener: () => void,): this
Jump to headingprependOnceListener(event: "data",listener: (chunk: any) => void,): this
Jump to headingprependOnceListener(event: "drain",listener: () => void,): this
Jump to headingprependOnceListener(event: "end",listener: () => void,): this
Jump to headingprependOnceListener(event: "error",listener: (err: Error) => void,): this
Jump to headingprependOnceListener(event: "finish",listener: () => void,): this
Jump to headingprependOnceListener(event: "pause",listener: () => void,): this
Jump to headingprependOnceListener(event: "pipe",listener: (src: Readable) => void,): this
Jump to headingprependOnceListener(event: "readable",listener: () => void,): this
Jump to headingprependOnceListener(event: "resume",listener: () => void,): this
Jump to headingprependOnceListener(event: "unpipe",listener: (src: Readable) => void,): this
Jump to headingprependOnceListener(event: string | symbol,listener: (...args: any[]) => void,): this
Jump to headingremoveListener(event: "close",listener: () => void,): this
Jump to headingremoveListener(event: "data",listener: (chunk: any) => void,): this
Jump to headingremoveListener(event: "drain",listener: () => void,): this
Jump to headingremoveListener(event: "end",listener: () => void,): this
Jump to headingremoveListener(event: "error",listener: (err: Error) => void,): this
Jump to headingremoveListener(event: "finish",listener: () => void,): this
Jump to headingremoveListener(event: "pause",listener: () => void,): this
Jump to headingremoveListener(event: "pipe",listener: (src: Readable) => void,): this
Jump to headingremoveListener(event: "readable",listener: () => void,): this
Jump to headingremoveListener(event: "resume",listener: () => void,): this
Jump to headingremoveListener(event: "unpipe",listener: (src: Readable) => void,): this
Jump to headingremoveListener(event: string | symbol,listener: (...args: any[]) => void,): this
Jump to headingsetDefaultEncoding(encoding: BufferEncoding): this
Jump to headinguncork(): void
Jump to headingwrite(chunk: any,encoding?: BufferEncoding,cb?: (error: Error
| null
| undefined) => void,): boolean
Jump to headingwrite(chunk: any,cb?: (error: Error
| null
| undefined) => void,): boolean
Static Methods Jump to heading
Jump to headingfrom(src: Stream
| NodeBlob
| ArrayBuffer
| string
| Iterable<any>
| AsyncIterable<any>
| AsyncGeneratorFunction
| Promise<any>
| Object): Duplex
A utility method for creating duplex streams.
Stream
converts writable stream into writableDuplex
and readable stream toDuplex
.Blob
converts into readableDuplex
.string
converts into readableDuplex
.ArrayBuffer
converts into readableDuplex
.AsyncIterable
converts into a readableDuplex
. Cannot yieldnull
.AsyncGeneratorFunction
converts into a readable/writable transformDuplex
. Must take a sourceAsyncIterable
as first parameter. Cannot yieldnull
.AsyncFunction
converts into a writableDuplex
. Must return eithernull
orundefined
Object ({ writable, readable })
convertsreadable
andwritable
intoStream
and then combines them intoDuplex
where theDuplex
will write to thewritable
and read from thereadable
.Promise
converts into readableDuplex
. Valuenull
is ignored.
Jump to headingfromWeb(duplexStream: { readable: streamWeb.ReadableStream; writable: streamWeb.WritableStream; },options?: Pick<DuplexOptions, "allowHalfOpen"
| "decodeStrings"
| "encoding"
| "highWaterMark"
| "objectMode"
| "signal">,): Duplex
A utility method for creating a Duplex
from a web ReadableStream
and WritableStream
.
Jump to headingtoWeb(streamDuplex: Duplex): { readable: streamWeb.ReadableStream; writable: streamWeb.WritableStream; }
A utility method for creating a web ReadableStream
and WritableStream
from a Duplex
.