WriteStream

external class WriteStream : Writable(source)
  • Extends stream.Writable

Instances of fs.WriteStream are created and returned using the {@link createWriteStream} function.

Since

v0.1.93

Constructors

Link copied to clipboard
constructor(opts: WritableOptions<*> = definedExternally)

Properties

Link copied to clipboard
open external val _construct: (callback: (JsError?) -> Unit) -> Unit?
Link copied to clipboard
open external val _writev: (ReadonlyArray<WritableWritevChunksItem>, callback: (JsError?) -> Unit) -> Unit?
Link copied to clipboard
external var bytesWritten: Double

The number of bytes written so far. Does not include data that is still queued for writing.

Link copied to clipboard
open external val closed: Boolean

Is true after 'close' has been emitted.

Link copied to clipboard
open external override val closeEvent: EventInstance<Tuple>

events.EventEmitter

Link copied to clipboard
open external var destroyed: Boolean

Is true after writable.destroy() has been called.

Link copied to clipboard
open external override val drainEvent: EventInstance<Tuple>
Link copied to clipboard
open external val errored: JsError?

Returns error if the stream has been destroyed with an error.

Link copied to clipboard
open external override val errorEvent: EventInstance<Tuple1<JsError>>
Link copied to clipboard
open external override val finishEvent: EventInstance<Tuple>
Link copied to clipboard
Link copied to clipboard
external var path: Any

The path to the file the stream is writing to as specified in the first argument to {@link 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.

Link copied to clipboard
external var pending: Boolean

This property is true if the underlying file has not been opened yet, i.e. before the 'ready' event is emitted.

Link copied to clipboard
open external override val pipeEvent: EventInstance<Tuple1<Readable>>
Link copied to clipboard

Is true if it is safe to call writable.write(), which means the stream has not been destroyed, errored, or ended.

Link copied to clipboard
Link copied to clipboard
open external override val unpipeEvent: EventInstance<Tuple1<Readable>>
Link copied to clipboard
open external override var writable: Boolean
Link copied to clipboard
external val writableAborted: Boolean

Returns whether the stream was destroyed or errored before emitting 'finish'.

Link copied to clipboard
open external val writableCorked: Double

Number of times writable.uncork() needs to be called in order to fully uncork the stream.

Link copied to clipboard
open external val writableEnded: Boolean

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.

Link copied to clipboard
open external val writableFinished: Boolean

Is set to true immediately before the 'finish' event is emitted.

Link copied to clipboard
open external val writableHighWaterMark: Double

Return the value of highWaterMark passed when creating this Writable.

Link copied to clipboard
open external val writableLength: Double

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.

Link copied to clipboard
open external val writableNeedDrain: Boolean

Is true if the stream's buffer has been full and stream will emit 'drain'.

Link copied to clipboard
open external val writableObjectMode: Boolean

Getter for the property objectMode of a given Writable stream.

Functions

Link copied to clipboard
open external fun _destroy(error: JsError?, callback: (JsError?) -> Unit)
Link copied to clipboard
open external fun _final(callback: (JsError?) -> Unit)
Link copied to clipboard
open external fun _write(chunk: Any?, encoding: BufferEncoding, callback: (JsError?) -> Unit)
Link copied to clipboard
external fun addListener(type: EventType, listener: EventListener)

Alias for emitter.on(eventName, listener).

open external fun addListener(event: Symbol, listener: Function<Unit>)

open external fun addListener(event: String, listener: Function<Unit>)

Event emitter The defined events on documents including:

Link copied to clipboard
external fun close(callback: (err: ErrnoException?) -> Unit = definedExternally)

Closes writeStream. Optionally accepts a callback that will be executed once the writeStreamis closed.

Link copied to clipboard
external fun <T : ReadableStream> compose(stream: T, options: StreamComposeOptions = definedExternally): T
external fun <T : ReadableStream> compose(stream: AsyncIterable<T>, options: StreamComposeOptions = definedExternally): T
external fun <T : ReadableStream> compose(stream: JsIterable<T>, options: StreamComposeOptions = definedExternally): T
external fun <T : ReadableStream> compose(stream: ComposeFnParam, options: StreamComposeOptions = definedExternally): T
Link copied to clipboard
open external fun cork()

The writable.cork() method forces all written data to be buffered in memory. The buffered data will be flushed when either the {@link uncork} or {@link end} methods are called.

Link copied to clipboard
open external fun destroy()

Destroy the stream. Optionally emit an 'error' event, and emit a 'close' event (unless emitClose is set to 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.

open external fun destroy(error: JsError)
Link copied to clipboard
external fun emit(type: EventType, vararg args: Any?): Boolean

Synchronously calls each of the listeners registered for the event named eventName, in the order they were registered, passing the supplied arguments to each.

open external fun emit(event: Symbol, vararg args: Any?): Boolean
open external fun emit(event: String, vararg args: Any?): Boolean
Link copied to clipboard
open external override fun end(cb: () -> Unit = definedExternally)

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.

open external override fun end(data: Uint8Array<*>, cb: () -> Unit = definedExternally)
open external override fun end(data: String, cb: () -> Unit = definedExternally)
open external override fun end(str: String, encoding: BufferEncoding = definedExternally, cb: () -> Unit = definedExternally)

open external fun end(chunk: Any?, cb: () -> Unit = definedExternally)
open external fun end(chunk: Any?, encoding: BufferEncoding, cb: () -> Unit = definedExternally)

Signals that no more data will be written, with one final chunk of data.

Link copied to clipboard

Returns an array listing the events for which the emitter has registered listeners. The values in the array are strings or Symbols.

Link copied to clipboard
external fun getMaxListeners(): Double

Returns the current max listener value for the EventEmitter which is either set by emitter.setMaxListeners(n) or defaults to {@link EventEmitter.defaultMaxListeners}.

Link copied to clipboard
external fun listenerCount(type: EventType, listener: EventListener = definedExternally): Double

Returns the number of listeners listening for the event named eventName. If listener is provided, it will return how many times the listener is found in the list of the listeners of the event.

Link copied to clipboard

Returns a copy of the array of listeners for the event named eventName.

Link copied to clipboard
external fun off(type: EventType, listener: EventListener)

Alias for emitter.removeListener().

Link copied to clipboard
external fun on(type: EventType, listener: EventListener)

Adds the listener function to the end of the listeners array for the event named eventName. No checks are made to see if the listener has already been added. Multiple calls passing the same combination of eventName and listener will result in the listener being added, and called, multiple times.

open external fun on(event: Symbol, listener: Function<Unit>)
open external fun on(event: String, listener: Function<Unit>)
Link copied to clipboard
external fun once(type: EventType, listener: EventListener)

Adds a one-time listener function for the event named eventName. The next time eventName is triggered, this listener is removed and then invoked.

open external fun once(event: Symbol, listener: Function<Unit>)
open external fun once(event: String, listener: Function<Unit>)
Link copied to clipboard
external fun <T : WritableStream> pipe(destination: T, options: StreamPipeOptions = definedExternally): T
Link copied to clipboard
external fun prependListener(type: EventType, listener: EventListener)

Adds the listener function to the beginning of the listeners array for the event named eventName. No checks are made to see if the listener has already been added. Multiple calls passing the same combination of eventName and listener will result in the listener being added, and called, multiple times.

open external fun prependListener(event: Symbol, listener: Function<Unit>)
open external fun prependListener(event: String, listener: Function<Unit>)
Link copied to clipboard
external fun prependOnceListener(type: EventType, listener: EventListener)

Adds a one-timelistener function for the event named eventName to the beginning of the listeners array. The next time eventName is triggered, this listener is removed, and then invoked.

open external fun prependOnceListener(event: Symbol, listener: Function<Unit>)
open external fun prependOnceListener(event: String, listener: Function<Unit>)
Link copied to clipboard

Returns a copy of the array of listeners for the event named eventName, including any wrappers (such as those created by .once()).

Link copied to clipboard
external fun removeAllListeners(type: EventType = definedExternally)

Removes all listeners, or those of the specified eventName.

Link copied to clipboard
external fun removeListener(type: EventType, listener: EventListener)

Removes the specified listener from the listener array for the event named eventName.

open external fun removeListener(event: Symbol, listener: Function<Unit>)
open external fun removeListener(event: String, listener: Function<Unit>)
Link copied to clipboard
open external fun setDefaultEncoding(encoding: BufferEncoding)

The writable.setDefaultEncoding() method sets the default encoding for a Writable stream.

Link copied to clipboard
external fun setMaxListeners(n: Number)

By default EventEmitters will print a warning if more than 10 listeners are added for a particular event. This is a useful default that helps finding memory leaks. The emitter.setMaxListeners() method allows the limit to be modified for this specific EventEmitter instance. The value can be set to Infinity (or 0) to indicate an unlimited number of listeners.

Link copied to clipboard
open external fun uncork()

The writable.uncork() method flushes all data buffered since {@link cork} was called.

Link copied to clipboard
open external override fun write(buffer: Uint8Array<*>, cb: (JsError?) -> Unit = definedExternally): Boolean
open external override fun write(buffer: String, cb: (JsError?) -> Unit = definedExternally): Boolean
open external override fun write(str: String, encoding: BufferEncoding = definedExternally, cb: (JsError?) -> Unit = definedExternally): Boolean

open external fun write(chunk: Any?, callback: (JsError?) -> Unit = definedExternally): Boolean

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.

open external fun write(chunk: Any?, encoding: BufferEncoding, callback: (JsError?) -> Unit = definedExternally): Boolean

Writes data to the stream, with an explicit encoding for string data.