Skip to main content
Deno 2 is finally here 🎉️
Learn more
Module

std/node/stream.ts>Duplex

Deno standard library
Go to Latest
The Standard Library has been moved to JSR. See the blog post for details.
class Duplex
extends Stream
Re-export
import { Duplex } from "https://deno.land/std@0.92.0/node/stream.ts";

A duplex is an implementation of a stream that has both Readable and Writable attributes and capabilities

Constructors

new
Duplex(options?: DuplexOptions)

Properties

optional
_final: (callback: (error?: Error | null | undefined) => void) => void
_read
_readableState: ReadableState
_undestroy
_writableState: WritableState
_write
optional
_writev: writeV | null
allowHalfOpen: boolean
cork
destroyed: boolean
isPaused
off
pause
pipe
readable: boolean
readonly
readableBuffer
readonly
readableEncoding
readonly
readableEnded
readableFlowing: boolean | null
readonly
readableHighWaterMark: number
readonly
readableLength
readonly
readableObjectMode
resume
setEncoding
uncork
unpipe
wrap
writable
readonly
writableBuffer
readonly
writableCorked
readonly
writableEnded
readonly
writableFinished
readonly
writableHighWaterMark
readonly
writableLength
readonly
writableObjectMode
write

Methods

_destroy(error: Error | null, callback: (error?: Error | null) => void): void
destroy(err?: Error | null, cb?: (error?: Error | null) => void)
end(cb?: () => void): void
end(chunk: any, cb?: () => void): void
end(
chunk: any,
encoding: Encodings,
cb?: () => void,
): void
on(event:
| "close"
| "end"
| "pause"
| "readable"
| "resume"
, listener: () => void
): this
on(event: "data", listener: (chunk: any) => void): this
on(event: "error", listener: (err: Error) => void): this
on(event: string | symbol, listener: (...args: any[]) => void): this
push(chunk: any, encoding?: Encodings): boolean
read(n?: number)

You can override either this method, or the async _read method

removeAllListeners(ev:
| "close"
| "data"
| "end"
| "error"
| "pause"
| "readable"
| "resume"
| symbol
| undefined
)
removeListener(event:
| "close"
| "end"
| "pause"
| "readable"
| "resume"
, listener: () => void
): this
removeListener(event: "data", listener: (chunk: any) => void): this
removeListener(event: "error", listener: (err: Error) => void): this
removeListener(event: string | symbol, listener: (...args: any[]) => void): this
setDefaultEncoding(encoding: string)
unshift(chunk: any, encoding?: Encodings): boolean
[Symbol.asyncIterator](): ReadableStreamAsyncIterator