import { Duplex } from "https://deno.land/std@0.161.0/node/_stream.d.ts";
Duplex streams are streams that implement both the Readable
and Writable
interfaces.
Examples of Duplex
streams include:
TCP sockets
zlib streams
crypto streams
Properties
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 false
.
This can be changed manually to change the half-open behavior of an existingDuplex
stream instance, but must be changed before the 'end'
event is
emitted.
Methods
_destroy(error: Error | null, callback: (error: Error | null) => void): void
_final(callback: (error?: Error | null) => void): void
_write(): void
chunk: any,
encoding: BufferEncoding,
callback: (error?: Error | null) => void,
optional
_writev(chunks: Array<{ chunk: any; encoding: BufferEncoding; }>, callback: (error?: Error | null) => void): voidcork(): void
end(cb?: () => void): void
end(chunk: any, cb?: () => void): void
end(): void
chunk: any,
encoding?: BufferEncoding,
cb?: () => void,
setDefaultEncoding(encoding: BufferEncoding): this
uncork(): void
write(): boolean
chunk: any,
encoding?: BufferEncoding,
cb?: (error: Error | null | undefined) => void,
write(chunk: any, cb?: (error: Error | null | undefined) => void): boolean
Static Methods
from(src: ): Duplex
| Stream
| Blob
| ArrayBuffer
| string
| Iterable<any>
| AsyncIterable<any>
| AsyncGeneratorFunction
| Promise<any>
| Object
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.