class Writable<TSelf>
package js.node.stream
extends Stream › EventEmitter
extended by Sign, Verify, WriteStream, ClientRequest, ServerResponse
The Writable stream interface is an abstraction for a destination that you are writing data to.
Examples of writable streams include:
- http requests, on the client
- http responses, on the server
- fs write streams
- zlib streams
- crypto streams
- tcp sockets
- child process stdin
- process.stdout, process.stderr
Constructor
Variables
read onlyisTTY:Bool
Terminal write streams (i.e. process.stdout) have this property set to true. It is false for any other write streams.
See also:
read onlywritableEnded:Bool
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:
read onlywritableFinished:Bool
read onlywritableLength:Int
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:
read onlywritableObjectMode:Bool
read onlywritablehighWaterMark:Int
Methods
cork():Void
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(?error:Error):TSelf
Destroy the stream. Optionally emit an 'error'
event, and emit a 'close'
event unless emitClose
is set in 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 to write()
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.
Implementors should not override this method, but instead implement writable._destroy()
.
See also:
end(chunk:Dynamic, ?encoding:String, ?callback:EitherType<() ‑> Void, Null<Error> ‑> Void>):Void
end(?callback:EitherType<() ‑> Void, Null<Error> ‑> Void>):Void
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:
setDefaultEncoding(encoding:String):TSelf
The writable.setDefaultEncoding()
method sets the default encoding
for a Writable stream.
See also:
uncork():Void
The writable.uncork()
method flushes all data buffered since stream.cork()
was called.
See also:
write(chunk:Dynamic, ?encoding:String, ?callback:EitherType<() ‑> Void, Null<Error> ‑> Void>):Bool
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: