WriteStream
Defined in: src/node/streams.ts:90
A WriteStream implementation that wraps an underlying global WritableStream.
Extends
Section titled “Extends”Writable
Implements
Section titled “Implements”WriteStream
Constructors
Section titled “Constructors”Constructor
Section titled “Constructor”new WriteStream(
opts?,handleOrPromise):WriteStream
Defined in: src/node/streams.ts:97
Parameters
Section titled “Parameters”CreateWriteStreamOptions = {}
handleOrPromise
Section titled “handleOrPromise”FileHandle | Promise<FileHandle>
Returns
Section titled “Returns”WriteStream
Overrides
Section titled “Overrides”Writable.constructor
Properties
Section titled “Properties”_events
Section titled “_events”_events:
Listeners
Defined in: node_modules/@zenfs/streams/dist/events.d.ts:28
Inherited from
Section titled “Inherited from”Writable._events
_eventsCount
Section titled “_eventsCount”_eventsCount:
number
Defined in: node_modules/@zenfs/streams/dist/events.d.ts:29
Inherited from
Section titled “Inherited from”Writable._eventsCount
_maxListeners?
Section titled “_maxListeners?”
optional_maxListeners?:number
Defined in: node_modules/@zenfs/streams/dist/events.d.ts:30
Inherited from
Section titled “Inherited from”Writable._maxListeners
_readableState?
Section titled “_readableState?”
optional_readableState?:ReadableState
Defined in: node_modules/@zenfs/streams/dist/writable.d.ts:126
Present on a Duplex; undefined on a plain Writable.
Inherited from
Section titled “Inherited from”Writable._readableState
_writableState
Section titled “_writableState”_writableState:
WritableState
Defined in: node_modules/@zenfs/streams/dist/writable.d.ts:124
Inherited from
Section titled “Inherited from”Writable._writableState
[kCapture]
Section titled “[kCapture]”
protected[kCapture]:boolean
Defined in: node_modules/@zenfs/streams/dist/events.d.ts:31
Inherited from
Section titled “Inherited from”Writable.[kCapture]
pending
Section titled “pending”pending:
boolean=true
Defined in: src/node/streams.ts:91
This property is true if the underlying file has not been opened yet,
i.e. before the 'ready' event is emitted.
v11.2.0
Implementation of
Section titled “Implementation of”fs.WriteStream.pending
captureRejections
Section titled “captureRejections”
staticcaptureRejections:boolean
Defined in: node_modules/@zenfs/streams/dist/events.d.ts:25
The default for the captureRejections option of newly created emitters.
Inherited from
Section titled “Inherited from”Writable.captureRejections
captureRejectionSymbol
Section titled “captureRejectionSymbol”
readonlystaticcaptureRejectionSymbol: typeofcaptureRejectionSymbol
Defined in: node_modules/@zenfs/streams/dist/events.d.ts:26
Inherited from
Section titled “Inherited from”Writable.captureRejectionSymbol
defaultMaxListeners
Section titled “defaultMaxListeners”
staticdefaultMaxListeners:number
Defined in: node_modules/@zenfs/streams/dist/events.d.ts:23
Inherited from
Section titled “Inherited from”Writable.defaultMaxListeners
errorMonitor
Section titled “errorMonitor”
readonlystaticerrorMonitor: typeoferrorMonitor
Defined in: node_modules/@zenfs/streams/dist/events.d.ts:27
Inherited from
Section titled “Inherited from”Writable.errorMonitor
WritableState
Section titled “WritableState”
readonlystaticWritableState: typeofWritableState
Defined in: node_modules/@zenfs/streams/dist/writable.d.ts:128
Inherited from
Section titled “Inherited from”Writable.WritableState
Accessors
Section titled “Accessors”bytesWritten
Section titled “bytesWritten”Get Signature
Section titled “Get Signature”get bytesWritten():
number
Defined in: src/node/streams.ts:154
The number of bytes written so far. Does not include data that is still queued for writing.
v0.4.7
Returns
Section titled “Returns”number
Implementation of
Section titled “Implementation of”fs.WriteStream.bytesWritten
closed
Section titled “closed”Get Signature
Section titled “Get Signature”get closed():
boolean
Defined in: node_modules/@zenfs/streams/dist/writable.d.ts:145
Is true after 'close' has been emitted.
v18.0.0
Returns
Section titled “Returns”boolean
Implementation of
Section titled “Implementation of”fs.WriteStream.closed
Inherited from
Section titled “Inherited from”Writable.closed
destroyed
Section titled “destroyed”Get Signature
Section titled “Get Signature”get destroyed():
boolean
Defined in: node_modules/@zenfs/streams/dist/writable.d.ts:146
Is true after writable.destroy() has been called.
v8.0.0
Returns
Section titled “Returns”boolean
Set Signature
Section titled “Set Signature”set destroyed(
value):void
Defined in: node_modules/@zenfs/streams/dist/writable.d.ts:147
Is true after writable.destroy() has been called.
v8.0.0
Parameters
Section titled “Parameters”boolean
Returns
Section titled “Returns”void
Implementation of
Section titled “Implementation of”fs.WriteStream.destroyed
Inherited from
Section titled “Inherited from”Writable.destroyed
errored
Section titled “errored”Get Signature
Section titled “Get Signature”get errored():
Error|null
Defined in: node_modules/@zenfs/streams/dist/writable.d.ts:158
Returns error if the stream has been destroyed with an error.
v18.0.0
Returns
Section titled “Returns”Error | null
Implementation of
Section titled “Implementation of”fs.WriteStream.errored
Inherited from
Section titled “Inherited from”Writable.errored
Get Signature
Section titled “Get Signature”get path():
string
Defined in: src/node/streams.ts:150
The path to the file the stream is writing to as specified in the first
argument to createWriteStream. If path is passed as a string, thenwriteStream.path will be a string. If path is passed as a Buffer, thenwriteStream.path will be a
Buffer.
v0.1.93
Returns
Section titled “Returns”string
Implementation of
Section titled “Implementation of”fs.WriteStream.path
writable
Section titled “writable”Get Signature
Section titled “Get Signature”get writable():
boolean
Defined in: node_modules/@zenfs/streams/dist/writable.d.ts:148
Is true if it is safe to call writable.write(), which means
the stream has not been destroyed, errored, or ended.
v11.4.0
Returns
Section titled “Returns”boolean
Set Signature
Section titled “Set Signature”set writable(
value):void
Defined in: node_modules/@zenfs/streams/dist/writable.d.ts:149
Is true if it is safe to call writable.write(), which means
the stream has not been destroyed, errored, or ended.
v11.4.0
Parameters
Section titled “Parameters”boolean
Returns
Section titled “Returns”void
Implementation of
Section titled “Implementation of”fs.WriteStream.writable
Inherited from
Section titled “Inherited from”Writable.writable
writableAborted
Section titled “writableAborted”Get Signature
Section titled “Get Signature”get writableAborted():
boolean
Defined in: node_modules/@zenfs/streams/dist/writable.d.ts:159
Returns whether the stream was destroyed or errored before emitting 'finish'.
v18.0.0, v16.17.0
Returns
Section titled “Returns”boolean
Implementation of
Section titled “Implementation of”fs.WriteStream.writableAborted
Inherited from
Section titled “Inherited from”Writable.writableAborted
writableBuffer
Section titled “writableBuffer”Get Signature
Section titled “Get Signature”get writableBuffer():
BufferedWrite[] |undefined
Defined in: node_modules/@zenfs/streams/dist/writable.d.ts:152
Returns
Section titled “Returns”BufferedWrite[] | undefined
Inherited from
Section titled “Inherited from”Writable.writableBuffer
writableCorked
Section titled “writableCorked”Get Signature
Section titled “Get Signature”get writableCorked():
number
Defined in: node_modules/@zenfs/streams/dist/writable.d.ts:156
Number of times writable.uncork() needs to be
called in order to fully uncork the stream.
v13.2.0, v12.16.0
Returns
Section titled “Returns”number
Implementation of
Section titled “Implementation of”fs.WriteStream.writableCorked
Inherited from
Section titled “Inherited from”Writable.writableCorked
writableEnded
Section titled “writableEnded”Get Signature
Section titled “Get Signature”get writableEnded():
boolean
Defined in: node_modules/@zenfs/streams/dist/writable.d.ts:153
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.
v12.9.0
Returns
Section titled “Returns”boolean
Implementation of
Section titled “Implementation of”fs.WriteStream.writableEnded
Inherited from
Section titled “Inherited from”Writable.writableEnded
writableFinished
Section titled “writableFinished”Get Signature
Section titled “Get Signature”get writableFinished():
boolean
Defined in: node_modules/@zenfs/streams/dist/writable.d.ts:150
Is set to true immediately before the 'finish' event is emitted.
v12.6.0
Returns
Section titled “Returns”boolean
Implementation of
Section titled “Implementation of”fs.WriteStream.writableFinished
Inherited from
Section titled “Inherited from”Writable.writableFinished
writableHighWaterMark
Section titled “writableHighWaterMark”Get Signature
Section titled “Get Signature”get writableHighWaterMark():
number
Defined in: node_modules/@zenfs/streams/dist/writable.d.ts:155
Return the value of highWaterMark passed when creating this Writable.
v9.3.0
Returns
Section titled “Returns”number
Implementation of
Section titled “Implementation of”fs.WriteStream.writableHighWaterMark
Inherited from
Section titled “Inherited from”Writable.writableHighWaterMark
writableLength
Section titled “writableLength”Get Signature
Section titled “Get Signature”get writableLength():
number
Defined in: node_modules/@zenfs/streams/dist/writable.d.ts:157
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.
v9.4.0
Returns
Section titled “Returns”number
Implementation of
Section titled “Implementation of”fs.WriteStream.writableLength
Inherited from
Section titled “Inherited from”Writable.writableLength
writableNeedDrain
Section titled “writableNeedDrain”Get Signature
Section titled “Get Signature”get writableNeedDrain():
boolean
Defined in: node_modules/@zenfs/streams/dist/writable.d.ts:154
Is true if the stream’s buffer has been full and stream will emit 'drain'.
v15.2.0, v14.17.0
Returns
Section titled “Returns”boolean
Implementation of
Section titled “Implementation of”fs.WriteStream.writableNeedDrain
Inherited from
Section titled “Inherited from”Writable.writableNeedDrain
writableObjectMode
Section titled “writableObjectMode”Get Signature
Section titled “Get Signature”get writableObjectMode():
boolean
Defined in: node_modules/@zenfs/streams/dist/writable.d.ts:151
Getter for the property objectMode of a given Writable stream.
v12.3.0
Returns
Section titled “Returns”boolean
Implementation of
Section titled “Implementation of”fs.WriteStream.writableObjectMode
Inherited from
Section titled “Inherited from”Writable.writableObjectMode
Methods
Section titled “Methods”_construct()?
Section titled “_construct()?”
optional_construct(callback):void
Defined in: node_modules/@zenfs/streams/dist/writable.d.ts:141
Parameters
Section titled “Parameters”callback
Section titled “callback”Callback
Returns
Section titled “Returns”void
Implementation of
Section titled “Implementation of”fs.WriteStream._construct
Inherited from
Section titled “Inherited from”Writable._construct
_destroy()
Section titled “_destroy()”_destroy(
error,callback):void
Defined in: node_modules/@zenfs/streams/dist/writable.d.ts:162
Parameters
Section titled “Parameters”Error | null
callback
Section titled “callback”Callback
Returns
Section titled “Returns”void
Implementation of
Section titled “Implementation of”fs.WriteStream._destroy
Inherited from
Section titled “Inherited from”Writable._destroy
_final()
Section titled “_final()”_final(
callback):Promise<void>
Defined in: src/node/streams.ts:127
Parameters
Section titled “Parameters”callback
Section titled “callback”(error?) => void
Returns
Section titled “Returns”Promise<void>
Implementation of
Section titled “Implementation of”fs.WriteStream._final
Overrides
Section titled “Overrides”Writable._final
_undestroy()
Section titled “_undestroy()”_undestroy():
void
Defined in: node_modules/@zenfs/streams/dist/writable.d.ts:161
Returns
Section titled “Returns”void
Inherited from
Section titled “Inherited from”Writable._undestroy
_write()
Section titled “_write()”_write(
chunk,encoding,callback):Promise<void>
Defined in: src/node/streams.ts:110
Parameters
Section titled “Parameters”any
encoding
Section titled “encoding”"buffer" | BufferEncoding
callback
Section titled “callback”(error?) => void
Returns
Section titled “Returns”Promise<void>
Implementation of
Section titled “Implementation of”fs.WriteStream._write
Overrides
Section titled “Overrides”Writable._write
_writev()?
Section titled “_writev()?”
optional_writev(chunks,callback):void
Defined in: node_modules/@zenfs/streams/dist/writable.d.ts:140
Parameters
Section titled “Parameters”chunks
Section titled “chunks”WriteRequest[]
callback
Section titled “callback”Callback
Returns
Section titled “Returns”void
Implementation of
Section titled “Implementation of”fs.WriteStream._writev
Inherited from
Section titled “Inherited from”Writable._writev
[asyncDispose]()
Section titled “[asyncDispose]()”[asyncDispose]():
Promise<void>
Defined in: node_modules/@zenfs/streams/dist/writable.d.ts:168
Returns
Section titled “Returns”Promise<void>
Implementation of
Section titled “Implementation of”fs.WriteStream.[asyncDispose]
Inherited from
Section titled “Inherited from”Writable.[asyncDispose]
[captureRejectionSymbol]()
Section titled “[captureRejectionSymbol]()”[captureRejectionSymbol](
err):void
Defined in: node_modules/@zenfs/streams/dist/writable.d.ts:163
Parameters
Section titled “Parameters”Error
Returns
Section titled “Returns”void
Inherited from
Section titled “Inherited from”Writable.[captureRejectionSymbol]
addListener()
Section titled “addListener()”addListener(
type,listener):this
Defined in: node_modules/@zenfs/streams/dist/events.d.ts:36
Parameters
Section titled “Parameters”EventKey
listener
Section titled “listener”Listener
Returns
Section titled “Returns”this
Implementation of
Section titled “Implementation of”fs.WriteStream.addListener
Inherited from
Section titled “Inherited from”Writable.addListener
close()
Section titled “close()”close(
callback?):void
Defined in: src/node/streams.ts:140
Closes writeStream. Optionally accepts a
callback that will be executed once the writeStreamis closed.
Parameters
Section titled “Parameters”callback?
Section titled “callback?”Callback<[void]> = ...
Returns
Section titled “Returns”void
v0.9.4
Implementation of
Section titled “Implementation of”fs.WriteStream.close
cork()
Section titled “cork()”cork():
void
Defined in: node_modules/@zenfs/streams/dist/writable.d.ts:136
Buffers writes until a matching number of uncork() calls.
Returns
Section titled “Returns”void
Implementation of
Section titled “Implementation of”fs.WriteStream.cork
Inherited from
Section titled “Inherited from”Writable.cork
destroy()
Section titled “destroy()”destroy(
error?,callback?):this
Defined in: node_modules/@zenfs/streams/dist/writable.d.ts:160
Parameters
Section titled “Parameters”error?
Section titled “error?”Error | null
callback?
Section titled “callback?”Callback
Returns
Section titled “Returns”this
Implementation of
Section titled “Implementation of”fs.WriteStream.destroy
Inherited from
Section titled “Inherited from”Writable.destroy
emit()
Section titled “emit()”emit(
type, …args):boolean
Defined in: node_modules/@zenfs/streams/dist/events.d.ts:35
Parameters
Section titled “Parameters”EventKey
…any[]
Returns
Section titled “Returns”boolean
Implementation of
Section titled “Implementation of”fs.WriteStream.emit
Inherited from
Section titled “Inherited from”Writable.emit
Call Signature
Section titled “Call Signature”end(
callback?):this
Defined in: node_modules/@zenfs/streams/dist/writable.d.ts:142
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.
Calling the write method after calling end will raise an error.
// Write 'hello, ' and then end with 'world!'.import fs from 'node:fs';const file = fs.createWriteStream('example.txt');file.write('hello, ');file.end('world!');// Writing more now is not allowed!Parameters
Section titled “Parameters”callback?
Section titled “callback?”Callback
Returns
Section titled “Returns”this
v0.9.4
Implementation of
Section titled “Implementation of”fs.WriteStream.end
Inherited from
Section titled “Inherited from”Writable.end
Call Signature
Section titled “Call Signature”end(
chunk,callback?):this
Defined in: node_modules/@zenfs/streams/dist/writable.d.ts:143
Signals that no more data will be written, with one final chunk of data.
Parameters
Section titled “Parameters”any
Optional data to write. For streams not operating in object mode, chunk must be a {string}, {Buffer},
{TypedArray} or {DataView}. For object mode streams, chunk may be any JavaScript value other than null.
callback?
Section titled “callback?”Callback
Returns
Section titled “Returns”this
Writable.end for full details.
v0.9.4
Implementation of
Section titled “Implementation of”fs.WriteStream.end
Inherited from
Section titled “Inherited from”Writable.end
Call Signature
Section titled “Call Signature”end(
chunk,encoding?,callback?):this
Defined in: node_modules/@zenfs/streams/dist/writable.d.ts:144
Signals that no more data will be written, with one final chunk of data.
Parameters
Section titled “Parameters”any
Optional data to write. For streams not operating in object mode, chunk must be a {string}, {Buffer},
{TypedArray} or {DataView}. For object mode streams, chunk may be any JavaScript value other than null.
encoding?
Section titled “encoding?”BufferEncoding | null
The encoding if chunk is a string
callback?
Section titled “callback?”Callback
Returns
Section titled “Returns”this
Writable.end for full details.
v0.9.4
Implementation of
Section titled “Implementation of”fs.WriteStream.end
Inherited from
Section titled “Inherited from”Writable.end
eventNames()
Section titled “eventNames()”eventNames():
EventKey[]
Defined in: node_modules/@zenfs/streams/dist/events.d.ts:47
Returns
Section titled “Returns”EventKey[]
Implementation of
Section titled “Implementation of”fs.WriteStream.eventNames
Inherited from
Section titled “Inherited from”Writable.eventNames
getMaxListeners()
Section titled “getMaxListeners()”getMaxListeners():
number
Defined in: node_modules/@zenfs/streams/dist/events.d.ts:34
Returns
Section titled “Returns”number
Implementation of
Section titled “Implementation of”fs.WriteStream.getMaxListeners
Inherited from
Section titled “Inherited from”Writable.getMaxListeners
listenerCount()
Section titled “listenerCount()”listenerCount(
type,listener?):number
Defined in: node_modules/@zenfs/streams/dist/events.d.ts:46
Parameters
Section titled “Parameters”EventKey
listener?
Section titled “listener?”Listener
Returns
Section titled “Returns”number
Implementation of
Section titled “Implementation of”fs.WriteStream.listenerCount
Inherited from
Section titled “Inherited from”Writable.listenerCount
listeners()
Section titled “listeners()”listeners(
type):Listener[]
Defined in: node_modules/@zenfs/streams/dist/events.d.ts:44
Parameters
Section titled “Parameters”EventKey
Returns
Section titled “Returns”Listener[]
Implementation of
Section titled “Implementation of”fs.WriteStream.listeners
Inherited from
Section titled “Inherited from”Writable.listeners
off(
type,listener):this
Defined in: node_modules/@zenfs/streams/dist/events.d.ts:42
Parameters
Section titled “Parameters”EventKey
listener
Section titled “listener”Listener
Returns
Section titled “Returns”this
Implementation of
Section titled “Implementation of”fs.WriteStream.off
Inherited from
Section titled “Inherited from”Writable.off
on(
type,listener):this
Defined in: node_modules/@zenfs/streams/dist/events.d.ts:37
Parameters
Section titled “Parameters”EventKey
listener
Section titled “listener”Listener
Returns
Section titled “Returns”this
Implementation of
Section titled “Implementation of”fs.WriteStream.on
Inherited from
Section titled “Inherited from”Writable.on
once()
Section titled “once()”once(
type,listener):this
Defined in: node_modules/@zenfs/streams/dist/events.d.ts:39
Parameters
Section titled “Parameters”EventKey
listener
Section titled “listener”Listener
Returns
Section titled “Returns”this
Implementation of
Section titled “Implementation of”fs.WriteStream.once
Inherited from
Section titled “Inherited from”Writable.once
pipe()
Section titled “pipe()”pipe<
T>(dest):T
Defined in: node_modules/@zenfs/streams/dist/writable.d.ts:132
Writables are not readable, so piping from one is always an error.
Type Parameters
Section titled “Type Parameters”T extends PipeDestination
Parameters
Section titled “Parameters”T
Returns
Section titled “Returns”T
Implementation of
Section titled “Implementation of”fs.WriteStream.pipe
Inherited from
Section titled “Inherited from”Writable.pipe
prependListener()
Section titled “prependListener()”prependListener(
type,listener):this
Defined in: node_modules/@zenfs/streams/dist/events.d.ts:38
Parameters
Section titled “Parameters”EventKey
listener
Section titled “listener”Listener
Returns
Section titled “Returns”this
Implementation of
Section titled “Implementation of”fs.WriteStream.prependListener
Inherited from
Section titled “Inherited from”Writable.prependListener
prependOnceListener()
Section titled “prependOnceListener()”prependOnceListener(
type,listener):this
Defined in: node_modules/@zenfs/streams/dist/events.d.ts:40
Parameters
Section titled “Parameters”EventKey
listener
Section titled “listener”Listener
Returns
Section titled “Returns”this
Implementation of
Section titled “Implementation of”fs.WriteStream.prependOnceListener
Inherited from
Section titled “Inherited from”Writable.prependOnceListener
rawListeners()
Section titled “rawListeners()”rawListeners(
type):Listener[]
Defined in: node_modules/@zenfs/streams/dist/events.d.ts:45
Parameters
Section titled “Parameters”EventKey
Returns
Section titled “Returns”Listener[]
Implementation of
Section titled “Implementation of”fs.WriteStream.rawListeners
Inherited from
Section titled “Inherited from”Writable.rawListeners
removeAllListeners()
Section titled “removeAllListeners()”removeAllListeners(
type?):this
Defined in: node_modules/@zenfs/streams/dist/events.d.ts:43
Parameters
Section titled “Parameters”EventKey
Returns
Section titled “Returns”this
Implementation of
Section titled “Implementation of”fs.WriteStream.removeAllListeners
Inherited from
Section titled “Inherited from”Writable.removeAllListeners
removeListener()
Section titled “removeListener()”removeListener(
type,listener):this
Defined in: node_modules/@zenfs/streams/dist/events.d.ts:41
Parameters
Section titled “Parameters”EventKey
listener
Section titled “listener”Listener
Returns
Section titled “Returns”this
Implementation of
Section titled “Implementation of”fs.WriteStream.removeListener
Inherited from
Section titled “Inherited from”Writable.removeListener
setDefaultEncoding()
Section titled “setDefaultEncoding()”setDefaultEncoding(
encoding):this
Defined in: node_modules/@zenfs/streams/dist/writable.d.ts:138
The writable.setDefaultEncoding() method sets the default encoding for a Writable stream.
Parameters
Section titled “Parameters”encoding
Section titled “encoding”BufferEncoding
The new default encoding
Returns
Section titled “Returns”this
v0.11.15
Implementation of
Section titled “Implementation of”fs.WriteStream.setDefaultEncoding
Inherited from
Section titled “Inherited from”Writable.setDefaultEncoding
setMaxListeners()
Section titled “setMaxListeners()”setMaxListeners(
n):this
Defined in: node_modules/@zenfs/streams/dist/events.d.ts:33
Parameters
Section titled “Parameters”number
Returns
Section titled “Returns”this
Implementation of
Section titled “Implementation of”fs.WriteStream.setMaxListeners
Inherited from
Section titled “Inherited from”Writable.setMaxListeners
uncork()
Section titled “uncork()”uncork():
void
Defined in: node_modules/@zenfs/streams/dist/writable.d.ts:137
The writable.uncork() method flushes all data buffered since cork was called.
When using writable.cork() and writable.uncork() to manage the buffering
of writes to a stream, defer calls to writable.uncork() using process.nextTick(). Doing so allows batching of all writable.write() calls that occur within a given Node.js event
loop phase.
stream.cork();stream.write('some ');stream.write('data ');process.nextTick(() => stream.uncork());If the writable.cork() method is called multiple times on a stream, the
same number of calls to writable.uncork() must be called to flush the buffered
data.
stream.cork();stream.write('some ');stream.cork();stream.write('data ');process.nextTick(() => { stream.uncork(); // The data will not be flushed until uncork() is called a second time. stream.uncork();});See also: writable.cork().
Returns
Section titled “Returns”void
v0.11.2
Implementation of
Section titled “Implementation of”fs.WriteStream.uncork
Inherited from
Section titled “Inherited from”Writable.uncork
write()
Section titled “write()”Call Signature
Section titled “Call Signature”write(
chunk,encoding?,callback?):boolean
Defined in: node_modules/@zenfs/streams/dist/writable.d.ts:133
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 will be called with the error as its
first argument. The callback is called asynchronously and before 'error' is
emitted.
The return value is true if the internal buffer is less than the highWaterMark configured when the stream was created after admitting chunk.
If false is returned, further attempts to write data to the stream should
stop until the 'drain' event is emitted.
While a stream is not draining, calls to write() will buffer chunk, and
return false. Once all currently buffered chunks are drained (accepted for
delivery by the operating system), the 'drain' event will be emitted.
Once write() returns false, do not write more chunks
until the 'drain' event is emitted. While calling write() on a stream that
is not draining is allowed, Node.js will buffer all written chunks until
maximum memory usage occurs, at which point it will abort unconditionally.
Even before it aborts, high memory usage will cause poor garbage collector
performance and high RSS (which is not typically released back to the system,
even after the memory is no longer required). Since TCP sockets may never
drain if the remote peer does not read the data, writing a socket that is
not draining may lead to a remotely exploitable vulnerability.
Writing data while the stream is not draining is particularly
problematic for a Transform, because the Transform streams are paused
by default until they are piped or a 'data' or 'readable' event handler
is added.
If the data to be written can be generated or fetched on demand, it is
recommended to encapsulate the logic into a Readable and use pipe. However, if calling write() is preferred, it is
possible to respect backpressure and avoid memory issues using the 'drain' event:
function write(data, cb) { if (!stream.write(data)) { stream.once('drain', cb); } else { process.nextTick(cb); }}
// Wait for cb to be called before doing any other write.write('hello', () => { console.log('Write completed, do more writes now.');});A Writable stream in object mode will always ignore the encoding argument.
Parameters
Section titled “Parameters”any
Optional data to write. For streams not operating in object mode, chunk must be a {string}, {Buffer},
{TypedArray} or {DataView}. For object mode streams, chunk may be any JavaScript value other than null.
encoding?
Section titled “encoding?”BufferEncoding | null
callback?
Section titled “callback?”Callback
Callback for when this chunk of data is flushed.
Returns
Section titled “Returns”boolean
false if the stream wishes for the calling code to wait for the 'drain' event to be emitted before continuing to write additional data; otherwise true.
v0.9.4
Implementation of
Section titled “Implementation of”fs.WriteStream.write
Inherited from
Section titled “Inherited from”Writable.write
Call Signature
Section titled “Call Signature”write(
chunk,callback?):boolean
Defined in: node_modules/@zenfs/streams/dist/writable.d.ts:134
Writes data to the stream, with an explicit encoding for string data.
Parameters
Section titled “Parameters”any
Optional data to write. For streams not operating in object mode, chunk must be a {string}, {Buffer},
{TypedArray} or {DataView}. For object mode streams, chunk may be any JavaScript value other than null.
callback?
Section titled “callback?”Callback
Callback for when this chunk of data is flushed.
Returns
Section titled “Returns”boolean
false if the stream wishes for the calling code to wait for the 'drain' event to be emitted before continuing to write additional data; otherwise true.
Writable.write for full details.
v0.9.4
Implementation of
Section titled “Implementation of”fs.WriteStream.write
Inherited from
Section titled “Inherited from”Writable.write
[hasInstance]()
Section titled “[hasInstance]()”
static[hasInstance](instance):boolean
Defined in: node_modules/@zenfs/streams/dist/writable.d.ts:130
Recognizes a Duplex, which inherits from Readable and so is not a structural subclass.
Parameters
Section titled “Parameters”instance
Section titled “instance”unknown
Returns
Section titled “Returns”boolean
Inherited from
Section titled “Inherited from”Writable.[hasInstance]
fromWeb()
Section titled “fromWeb()”
staticfromWeb(writableStream,options?):Writable
Defined in: node_modules/@zenfs/streams/dist/writable.d.ts:165
Wraps a WHATWG WritableStream.
Parameters
Section titled “Parameters”writableStream
Section titled “writableStream”WritableStream
options?
Section titled “options?”WritableOptions<Writable>
Returns
Section titled “Returns”Writable
Inherited from
Section titled “Inherited from”Writable.fromWeb
toWeb()
Section titled “toWeb()”
statictoWeb(streamWritable):WritableStream
Defined in: node_modules/@zenfs/streams/dist/writable.d.ts:167
Exposes this stream as a WHATWG WritableStream.
Parameters
Section titled “Parameters”streamWritable
Section titled “streamWritable”Writable
Returns
Section titled “Returns”WritableStream
Inherited from
Section titled “Inherited from”Writable.toWeb