Types

Link copied to clipboard
object Companion

Factory methods for creating Writable instances.

Properties

Link copied to clipboard
abstract val closed: Boolean

Is true after 'close' has been emitted.

Link copied to clipboard
abstract val destroyed: Boolean

Is true after destroy() has been called.

Link copied to clipboard
abstract val errored: Any?

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

Link copied to clipboard
abstract val writable: Boolean

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
abstract val writableAborted: Boolean

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

Link copied to clipboard
abstract val writableCorked: Int

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

Link copied to clipboard
abstract 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

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

Link copied to clipboard

Return the value of highWaterMark passed when creating this Writable.

Link copied to clipboard
abstract val writableLength: 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.

Link copied to clipboard

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

Link copied to clipboard

Getter for the property objectMode of a given Writable stream.

Functions

Link copied to clipboard
abstract fun addEventListener(type: String, listener: EventListener)
abstract fun addEventListener(type: String, options: AddEventListenerOptions, listener: EventListener)
abstract fun addEventListener(type: String, listener: Value, options: Value?)

Adds a new handler for the type event. Any given listener is added only once per type and per capture option value.

Link copied to clipboard
abstract fun addListener(eventName: String, listener: EventListener)
abstract fun addListener(eventName: String, listener: Value)

Alias for emitter.on(eventName, listener).

Link copied to clipboard
abstract override fun close()
Link copied to clipboard
abstract fun cork()

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.

Link copied to clipboard
abstract override fun destroy()
abstract override fun destroy(error: Throwable)
abstract override fun destroy(error: Value)

Destroy the stream. Optionally emit an 'error' event, and emit a 'close' event (unless emitClose is set to false).

Link copied to clipboard
abstract fun dispatchEvent(event: Event): Boolean

Dispatches the event to the list of handlers for Event.type.

Link copied to clipboard
abstract fun emit(eventName: String, 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.

Link copied to clipboard
abstract fun end()

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.

abstract fun end(chunk: StringOrBufferOrAny?, encoding: Value?)
abstract fun end(chunk: StringOrBufferOrAny?, encoding: Value? = null, callback: () -> Unit)
abstract fun end(chunk: StringOrBufferOrAny?, encoding: Value?, callback: Value?)

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.

Link copied to clipboard
abstract fun eventNames(): List<String>

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
abstract fun getMaxListeners(): Int

Returns the current max listener value for the emitter.

Link copied to clipboard
abstract fun listenerCount(eventName: String): Int

Returns the number of listeners listening to the event named eventName.

Link copied to clipboard
abstract fun listeners(eventName: String): List<EventListener>

Returns an array listing the listeners for the specified event.

Link copied to clipboard
abstract fun off(eventName: String, listener: Value)

Alias for emitter.removeListener(eventName, listener).

Link copied to clipboard
abstract fun on(eventName: String, listener: EventListener): EventEmitter
abstract fun on(eventName: String, listener: Value): EventEmitter

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.

Link copied to clipboard
abstract fun once(eventName: String, listener: EventListener)
abstract fun once(eventName: String, listener: Value)

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

Link copied to clipboard
abstract fun prependListener(eventName: String, listener: EventListener)
abstract fun prependListener(eventName: String, listener: Value)

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.

Link copied to clipboard
abstract fun prependOnceListener(eventName: String, listener: EventListener)
abstract fun prependOnceListener(eventName: String, listener: Value)

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

Link copied to clipboard
abstract fun rawListeners(eventName: String): List<EventListener>

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
abstract fun removeAllListeners()

Removes all listeners, or those of the specified eventName.

abstract fun removeAllListeners(eventName: String)

Removes all listeners, or those of the specified eventName.

Link copied to clipboard
abstract fun removeEventListener(type: String, listener: EventListener)
abstract fun removeEventListener(type: String, listener: Value)
abstract fun removeEventListener(type: String, listener: EventListener, options: RemoveEventListenerOptions)
abstract fun removeEventListener(type: String, listener: EventListener, options: Value)
abstract fun removeEventListener(type: String, listener: Value, options: Value)

Removes the listener from the list of handlers for event type.

Link copied to clipboard
abstract fun removeListener(eventName: String, listener: Value)

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

Link copied to clipboard
abstract fun setMaxListeners(count: Int)

Sets the maximum number of listeners for the emitter.

Link copied to clipboard
abstract fun write(chunk: Any?)
abstract fun write(chunk: StringOrBufferOrAny?, encoding: Value?)
abstract fun write(chunk: StringOrBufferOrAny?, encoding: Value? = null, callback: () -> Unit)
abstract fun write(chunk: StringOrBufferOrAny?, encoding: Value?, callback: Value?)

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.