Packages

class Writable extends Object with StObject with WritableStream

Annotations
@JSType() @JSImport("stream", "Writable") @native()
Since

v0.9.4

Linear Supertypes
WritableStream, EventEmitter, StObject, Object, Any, AnyRef, Any
Ordering
  1. Alphabetic
  2. By Inheritance
Inherited
  1. Writable
  2. WritableStream
  3. EventEmitter
  4. StObject
  5. Object
  6. Any
  7. AnyRef
  8. Any
  1. Hide All
  2. Show All
Visibility
  1. Public
  2. Protected

Instance Constructors

  1. new Writable(opts: WritableOptions)
  2. new Writable()

Value Members

  1. final def !=(arg0: Any): Boolean
    Definition Classes
    AnyRef → Any
  2. final def ##: Int
    Definition Classes
    AnyRef → Any
  3. final def ==(arg0: Any): Boolean
    Definition Classes
    AnyRef → Any
  4. var _construct: UndefOr[Function1[Function1[UndefOr[|[Error, Null]], Unit], Unit]]
  5. def _destroy(error: Null, callback: Function1[UndefOr[|[Error, Null]], Unit]): Unit
  6. def _destroy(error: Error, callback: Function1[UndefOr[|[Error, Null]], Unit]): Unit
  7. def _final(callback: Function1[UndefOr[|[Error, Null]], Unit]): Unit
  8. def _write(chunk: Any, encoding: BufferEncoding, callback: Function1[UndefOr[|[Error, Null]], Unit]): Unit
  9. var _writev: UndefOr[Function2[Array[Chunk], Function1[UndefOr[|[Error, Null]], Unit], Unit]]
  10. def addListener(eventName: Symbol, listener: Function1[Any, Unit]): Writable.this.type
    Definition Classes
    EventEmitter
  11. def addListener(eventName: String, listener: Function1[Any, Unit]): Writable.this.type

    Alias for emitter.on(eventName, listener).

    Alias for emitter.on(eventName, listener).

    Definition Classes
    EventEmitter
    Since

    v0.1.26

  12. def addListener_close(event: close, listener: Function0[Unit]): Writable.this.type

    Event emitter The defined events on documents including: 1.

    Event emitter The defined events on documents including: 1. close 2. drain 3. error 4. finish 5. pipe 6. unpipe

    Annotations
    @JSName("addListener")
  13. def addListener_drain(event: drain, listener: Function0[Unit]): Writable.this.type
    Annotations
    @JSName("addListener")
  14. def addListener_error(event: error, listener: Function1[Error, Unit]): Writable.this.type
    Annotations
    @JSName("addListener")
  15. def addListener_finish(event: finish, listener: Function0[Unit]): Writable.this.type
    Annotations
    @JSName("addListener")
  16. def addListener_pipe(event: pipe, listener: Function1[Readable, Unit]): Writable.this.type
    Annotations
    @JSName("addListener")
  17. def addListener_unpipe(event: unpipe, listener: Function1[Readable, Unit]): Writable.this.type
    Annotations
    @JSName("addListener")
  18. final def asInstanceOf[T0]: T0
    Definition Classes
    Any
  19. def clone(): AnyRef
    Attributes
    protected[lang]
    Definition Classes
    AnyRef
    Annotations
    @throws(classOf[java.lang.CloneNotSupportedException]) @native() @HotSpotIntrinsicCandidate()
  20. def cork(): Unit

    The writable.cork() method forces all written data to be buffered in memory.

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

    The primary intent of writable.cork() is to accommodate a situation in which several small chunks are written to the stream in rapid succession. Instead of immediately forwarding them to the underlying destination, writable.cork()buffers all the chunks until writable.uncork() is called, which will pass them all to writable._writev(), if present. This prevents a head-of-line blocking situation where data is being buffered while waiting for the first small chunk to be processed. However, use of writable.cork() without implementingwritable._writev() may have an adverse effect on throughput.

    See also: writable.uncork(), writable._writev().

    Since

    v0.11.2

  21. def destroy(error: Error): Unit
  22. def destroy(): Unit

    Destroy the stream.

    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 towrite() 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.

    Once destroy() has been called any further calls will be a no-op and no further errors except from _destroy() may be emitted as 'error'.

    Implementors should not override this method, but instead implement writable._destroy().

    Since

    v8.0.0

  23. var destroyed: Boolean

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

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

    Since

    v8.0.0

  24. def emit(eventName: Symbol, args: Any*): Boolean
    Definition Classes
    EventEmitter
  25. def emit(eventName: String, args: Any*): Boolean

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

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

    Returns true if the event had listeners, false otherwise.

    js const EventEmitter = require('events'); const myEmitter = new EventEmitter();

    // First listener myEmitter.on('event', function firstListener() { console.log('Helloooo! first listener'); }); // Second listener myEmitter.on('event', function secondListener(arg1, arg2) { console.log(event with parameters ${arg1}, ${arg2} in second listener); }); // Third listener myEmitter.on('event', function thirdListener(...args) { const parameters = args.join(', '); console.log(event with parameters ${parameters} in third listener); });

    console.log(myEmitter.listeners('event'));

    myEmitter.emit('event', 1, 2, 3, 4, 5);

    // Prints: // [ // [Function: firstListener], // [Function: secondListener], // [Function: thirdListener] // ] // Helloooo! first listener // event with parameters 1, 2 in second listener // event with parameters 1, 2, 3, 4, 5 in third listener

    Definition Classes
    EventEmitter
    Since

    v0.1.26

  26. def emit_close(event: close): Boolean
    Annotations
    @JSName("emit")
  27. def emit_drain(event: drain): Boolean
    Annotations
    @JSName("emit")
  28. def emit_error(event: error, err: Error): Boolean
    Annotations
    @JSName("emit")
  29. def emit_finish(event: finish): Boolean
    Annotations
    @JSName("emit")
  30. def emit_pipe(event: pipe, src: Readable): Boolean
    Annotations
    @JSName("emit")
  31. def emit_unpipe(event: unpipe, src: Readable): Boolean
    Annotations
    @JSName("emit")
  32. def end(chunk: Any, encoding: BufferEncoding, cb: Function0[Unit]): Unit
  33. def end(chunk: Any, encoding: BufferEncoding): Unit
  34. def end(chunk: Any, cb: Function0[Unit]): Unit
  35. def end(chunk: Any): Unit
  36. def end(str: String, encoding: Unit, cb: Function0[Unit]): Unit
    Definition Classes
    WritableStream
  37. def end(str: String, encoding: BufferEncoding, cb: Function0[Unit]): Unit
    Definition Classes
    WritableStream
  38. def end(str: String, encoding: BufferEncoding): Unit
    Definition Classes
    WritableStream
  39. def end(data: Uint8Array, cb: Function0[Unit]): Unit
    Definition Classes
    WritableStream
  40. def end(data: Uint8Array): Unit
    Definition Classes
    WritableStream
  41. def end(data: String, cb: Function0[Unit]): Unit
    Definition Classes
    WritableStream
  42. def end(data: String): Unit
    Definition Classes
    WritableStream
  43. def end(cb: Function0[Unit]): Unit
    Definition Classes
    WritableStream
  44. def end(): Unit
    Definition Classes
    WritableStream
  45. final def eq(arg0: AnyRef): Boolean
    Definition Classes
    AnyRef
  46. def equals(arg0: AnyRef): Boolean
    Definition Classes
    AnyRef → Any
  47. def eventNames(): Array[|[String, Symbol]]

    Returns an array listing the events for which the emitter has registered listeners.

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

    js const EventEmitter = require('events'); const myEE = new EventEmitter(); myEE.on('foo', () => {}); myEE.on('bar', () => {});

    const sym = Symbol('symbol'); myEE.on(sym, () => {});

    console.log(myEE.eventNames()); // Prints: [ 'foo', 'bar', Symbol(symbol) ]

    Definition Classes
    EventEmitter
    Since

    v6.0.0

  48. final def getClass(): Class[_ <: AnyRef]
    Definition Classes
    AnyRef → Any
    Annotations
    @native() @HotSpotIntrinsicCandidate()
  49. def getMaxListeners(): Double

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

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

    Definition Classes
    EventEmitter
    Since

    v1.0.0

  50. def hasOwnProperty(v: String): Boolean
    Definition Classes
    Object
  51. def hashCode(): Int
    Definition Classes
    AnyRef → Any
    Annotations
    @native() @HotSpotIntrinsicCandidate()
  52. final def isInstanceOf[T0]: Boolean
    Definition Classes
    Any
  53. def isPrototypeOf(v: Object): Boolean
    Definition Classes
    Object
  54. def listenerCount(eventName: Symbol): Double
    Definition Classes
    EventEmitter
  55. def listenerCount(eventName: String): Double

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

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

    eventName

    The name of the event being listened for

    Definition Classes
    EventEmitter
    Since

    v3.2.0

  56. def listeners(eventName: Symbol): Array[Function]
    Definition Classes
    EventEmitter
  57. def listeners(eventName: String): Array[Function]

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

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

    js server.on('connection', (stream) => { console.log('someone connected!'); }); console.log(util.inspect(server.listeners('connection'))); // Prints: [ [Function] ]

    Definition Classes
    EventEmitter
    Since

    v0.1.26

  58. final def ne(arg0: AnyRef): Boolean
    Definition Classes
    AnyRef
  59. final def notify(): Unit
    Definition Classes
    AnyRef
    Annotations
    @native() @HotSpotIntrinsicCandidate()
  60. final def notifyAll(): Unit
    Definition Classes
    AnyRef
    Annotations
    @native() @HotSpotIntrinsicCandidate()
  61. def off(eventName: Symbol, listener: Function1[Any, Unit]): Writable.this.type
    Definition Classes
    EventEmitter
  62. def off(eventName: String, listener: Function1[Any, Unit]): Writable.this.type

    Alias for emitter.removeListener().

    Alias for emitter.removeListener().

    Definition Classes
    EventEmitter
    Since

    v10.0.0

  63. def on(eventName: Symbol, listener: Function1[Any, Unit]): Writable.this.type
    Definition Classes
    EventEmitter
  64. def on(eventName: String, listener: Function1[Any, Unit]): Writable.this.type

    Adds the listener function to the end of the listeners array for the event named eventName.

    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 eventNameand listener will result in the listener being added, and called, multiple times.

    js server.on('connection', (stream) => { console.log('someone connected!'); });

    Returns a reference to the EventEmitter, so that calls can be chained.

    By default, event listeners are invoked in the order they are added. Theemitter.prependListener() method can be used as an alternative to add the event listener to the beginning of the listeners array.

    js const myEE = new EventEmitter(); myEE.on('foo', () => console.log('a')); myEE.prependListener('foo', () => console.log('b')); myEE.emit('foo'); // Prints: // b // a

    eventName

    The name of the event.

    listener

    The callback function

    Definition Classes
    EventEmitter
    Since

    v0.1.101

  65. def on_close(event: close, listener: Function0[Unit]): Writable.this.type
    Annotations
    @JSName("on")
  66. def on_drain(event: drain, listener: Function0[Unit]): Writable.this.type
    Annotations
    @JSName("on")
  67. def on_error(event: error, listener: Function1[Error, Unit]): Writable.this.type
    Annotations
    @JSName("on")
  68. def on_finish(event: finish, listener: Function0[Unit]): Writable.this.type
    Annotations
    @JSName("on")
  69. def on_pipe(event: pipe, listener: Function1[Readable, Unit]): Writable.this.type
    Annotations
    @JSName("on")
  70. def on_unpipe(event: unpipe, listener: Function1[Readable, Unit]): Writable.this.type
    Annotations
    @JSName("on")
  71. def once(eventName: Symbol, listener: Function1[Any, Unit]): Writable.this.type
    Definition Classes
    EventEmitter
  72. def once(eventName: String, listener: Function1[Any, Unit]): Writable.this.type

    Adds a **one-time**listener function for the event named eventName.

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

    js server.once('connection', (stream) => { console.log('Ah, we have our first user!'); });

    Returns a reference to the EventEmitter, so that calls can be chained.

    By default, event listeners are invoked in the order they are added. Theemitter.prependOnceListener() method can be used as an alternative to add the event listener to the beginning of the listeners array.

    js const myEE = new EventEmitter(); myEE.once('foo', () => console.log('a')); myEE.prependOnceListener('foo', () => console.log('b')); myEE.emit('foo'); // Prints: // b // a

    eventName

    The name of the event.

    listener

    The callback function

    Definition Classes
    EventEmitter
    Since

    v0.3.0

  73. def once_close(event: close, listener: Function0[Unit]): Writable.this.type
    Annotations
    @JSName("once")
  74. def once_drain(event: drain, listener: Function0[Unit]): Writable.this.type
    Annotations
    @JSName("once")
  75. def once_error(event: error, listener: Function1[Error, Unit]): Writable.this.type
    Annotations
    @JSName("once")
  76. def once_finish(event: finish, listener: Function0[Unit]): Writable.this.type
    Annotations
    @JSName("once")
  77. def once_pipe(event: pipe, listener: Function1[Readable, Unit]): Writable.this.type
    Annotations
    @JSName("once")
  78. def once_unpipe(event: unpipe, listener: Function1[Readable, Unit]): Writable.this.type
    Annotations
    @JSName("once")
  79. def prependListener(eventName: Symbol, listener: Function1[Any, Unit]): Writable.this.type
    Definition Classes
    EventEmitter
  80. def prependListener(eventName: String, listener: Function1[Any, Unit]): Writable.this.type

    Adds the listener function to the _beginning_ of the listeners array for the event named eventName.

    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 eventNameand listener will result in the listener being added, and called, multiple times.

    js server.prependListener('connection', (stream) => { console.log('someone connected!'); });

    Returns a reference to the EventEmitter, so that calls can be chained.

    eventName

    The name of the event.

    listener

    The callback function

    Definition Classes
    EventEmitter
    Since

    v6.0.0

  81. def prependListener_close(event: close, listener: Function0[Unit]): Writable.this.type
    Annotations
    @JSName("prependListener")
  82. def prependListener_drain(event: drain, listener: Function0[Unit]): Writable.this.type
    Annotations
    @JSName("prependListener")
  83. def prependListener_error(event: error, listener: Function1[Error, Unit]): Writable.this.type
    Annotations
    @JSName("prependListener")
  84. def prependListener_finish(event: finish, listener: Function0[Unit]): Writable.this.type
    Annotations
    @JSName("prependListener")
  85. def prependListener_pipe(event: pipe, listener: Function1[Readable, Unit]): Writable.this.type
    Annotations
    @JSName("prependListener")
  86. def prependListener_unpipe(event: unpipe, listener: Function1[Readable, Unit]): Writable.this.type
    Annotations
    @JSName("prependListener")
  87. def prependOnceListener(eventName: Symbol, listener: Function1[Any, Unit]): Writable.this.type
    Definition Classes
    EventEmitter
  88. def prependOnceListener(eventName: String, listener: Function1[Any, Unit]): Writable.this.type

    Adds a **one-time**listener function for the event named eventName to the_beginning_ of the listeners array.

    Adds a **one-time**listener 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.

    js server.prependOnceListener('connection', (stream) => { console.log('Ah, we have our first user!'); });

    Returns a reference to the EventEmitter, so that calls can be chained.

    eventName

    The name of the event.

    listener

    The callback function

    Definition Classes
    EventEmitter
    Since

    v6.0.0

  89. def prependOnceListener_close(event: close, listener: Function0[Unit]): Writable.this.type
    Annotations
    @JSName("prependOnceListener")
  90. def prependOnceListener_drain(event: drain, listener: Function0[Unit]): Writable.this.type
    Annotations
    @JSName("prependOnceListener")
  91. def prependOnceListener_error(event: error, listener: Function1[Error, Unit]): Writable.this.type
    Annotations
    @JSName("prependOnceListener")
  92. def prependOnceListener_finish(event: finish, listener: Function0[Unit]): Writable.this.type
    Annotations
    @JSName("prependOnceListener")
  93. def prependOnceListener_pipe(event: pipe, listener: Function1[Readable, Unit]): Writable.this.type
    Annotations
    @JSName("prependOnceListener")
  94. def prependOnceListener_unpipe(event: unpipe, listener: Function1[Readable, Unit]): Writable.this.type
    Annotations
    @JSName("prependOnceListener")
  95. def propertyIsEnumerable(v: String): Boolean
    Definition Classes
    Object
  96. def rawListeners(eventName: Symbol): Array[Function]
    Definition Classes
    EventEmitter
  97. def rawListeners(eventName: String): Array[Function]

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

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

    js const emitter = new EventEmitter(); emitter.once('log', () => console.log('log once'));

    // Returns a new Array with a function onceWrapper which has a property // listener which contains the original listener bound above const listeners = emitter.rawListeners('log'); const logFnWrapper = listeners[0];

    // Logs "log once" to the console and does not unbind the once event logFnWrapper.listener();

    // Logs "log once" to the console and removes the listener logFnWrapper();

    emitter.on('log', () => console.log('log persistently')); // Will return a new Array with a single function bound by .on() above const newListeners = emitter.rawListeners('log');

    // Logs "log persistently" twice newListeners[0](); emitter.emit('log');

    Definition Classes
    EventEmitter
    Since

    v9.4.0

  98. def removeAllListeners(event: Symbol): Writable.this.type
    Definition Classes
    EventEmitter
  99. def removeAllListeners(event: String): Writable.this.type
    Definition Classes
    EventEmitter
  100. def removeAllListeners(): Writable.this.type

    Removes all listeners, or those of the specified eventName.

    Removes all listeners, or those of the specified eventName.

    It is bad practice to remove listeners added elsewhere in the code, particularly when the EventEmitter instance was created by some other component or module (e.g. sockets or file streams).

    Returns a reference to the EventEmitter, so that calls can be chained.

    Definition Classes
    EventEmitter
    Since

    v0.1.26

  101. def removeListener(eventName: Symbol, listener: Function1[Any, Unit]): Writable.this.type
    Definition Classes
    EventEmitter
  102. def removeListener(eventName: String, listener: Function1[Any, Unit]): Writable.this.type

    Removes the specified listener from the listener array for the event namedeventName.

    Removes the specified listener from the listener array for the event namedeventName.

    js const callback = (stream) => { console.log('someone connected!'); }; server.on('connection', callback); // ... server.removeListener('connection', callback);

    removeListener() will remove, at most, one instance of a listener from the listener array. If any single listener has been added multiple times to the listener array for the specified eventName, then removeListener() must be called multiple times to remove each instance.

    Once an event is emitted, all listeners attached to it at the time of emitting are called in order. This implies that anyremoveListener() or removeAllListeners() calls _after_ emitting and_before_ the last listener finishes execution will not remove them fromemit() in progress. Subsequent events behave as expected.

    js const myEmitter = new MyEmitter();

    const callbackA = () => { console.log('A'); myEmitter.removeListener('event', callbackB); };

    const callbackB = () => { console.log('B'); };

    myEmitter.on('event', callbackA);

    myEmitter.on('event', callbackB);

    // callbackA removes listener callbackB but it will still be called. // Internal listener array at time of emit [callbackA, callbackB] myEmitter.emit('event'); // Prints: // A // B

    // callbackB is now removed. // Internal listener array [callbackA] myEmitter.emit('event'); // Prints: // A

    Because listeners are managed using an internal array, calling this will change the position indices of any listener registered _after_ the listener being removed. This will not impact the order in which listeners are called, but it means that any copies of the listener array as returned by the emitter.listeners() method will need to be recreated.

    When a single function has been added as a handler multiple times for a single event (as in the example below), removeListener() will remove the most recently added instance. In the example the once('ping')listener is removed:

    js const ee = new EventEmitter();

    function pong() { console.log('pong'); }

    ee.on('ping', pong); ee.once('ping', pong); ee.removeListener('ping', pong);

    ee.emit('ping'); ee.emit('ping');

    Returns a reference to the EventEmitter, so that calls can be chained.

    Definition Classes
    EventEmitter
    Since

    v0.1.26

  103. def removeListener_close(event: close, listener: Function0[Unit]): Writable.this.type
    Annotations
    @JSName("removeListener")
  104. def removeListener_drain(event: drain, listener: Function0[Unit]): Writable.this.type
    Annotations
    @JSName("removeListener")
  105. def removeListener_error(event: error, listener: Function1[Error, Unit]): Writable.this.type
    Annotations
    @JSName("removeListener")
  106. def removeListener_finish(event: finish, listener: Function0[Unit]): Writable.this.type
    Annotations
    @JSName("removeListener")
  107. def removeListener_pipe(event: pipe, listener: Function1[Readable, Unit]): Writable.this.type
    Annotations
    @JSName("removeListener")
  108. def removeListener_unpipe(event: unpipe, listener: Function1[Readable, Unit]): Writable.this.type
    Annotations
    @JSName("removeListener")
  109. def setDefaultEncoding(encoding: BufferEncoding): Writable.this.type

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

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

    encoding

    The new default encoding

    Since

    v0.11.15

  110. def setMaxListeners(n: Double): Writable.this.type

    By default EventEmitters will print a warning if more than 10 listeners are added for a particular event.

    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 toInfinity (or 0) to indicate an unlimited number of listeners.

    Returns a reference to the EventEmitter, so that calls can be chained.

    Definition Classes
    EventEmitter
    Since

    v0.3.5

  111. final def synchronized[T0](arg0: => T0): T0
    Definition Classes
    AnyRef
  112. def toLocaleString(): String
    Definition Classes
    Object
  113. def toString(): String
    Definition Classes
    AnyRef → Any
  114. def uncork(): Unit

    The writable.uncork() method flushes all data buffered since cork was called.

    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, it is recommended that calls to writable.uncork() be deferred using process.nextTick(). Doing so allows batching of allwritable.write() calls that occur within a given Node.js event loop phase.

    js 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.

    js 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().

    Since

    v0.11.2

  115. def valueOf(): Any
    Definition Classes
    Object
  116. final def wait(arg0: Long, arg1: Int): Unit
    Definition Classes
    AnyRef
    Annotations
    @throws(classOf[java.lang.InterruptedException])
  117. final def wait(arg0: Long): Unit
    Definition Classes
    AnyRef
    Annotations
    @throws(classOf[java.lang.InterruptedException]) @native()
  118. final def wait(): Unit
    Definition Classes
    AnyRef
    Annotations
    @throws(classOf[java.lang.InterruptedException])
  119. val writable: Boolean
    Definition Classes
    WritableStream
  120. val writableCorked: Double

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

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

    Since

    v13.2.0, v12.16.0

  121. val writableEnded: Boolean

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

    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.

    Since

    v12.9.0

  122. val writableFinished: Boolean

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

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

    Since

    v12.6.0

  123. val writableHighWaterMark: Double

    Return the value of highWaterMark passed when creating this Writable.

    Return the value of highWaterMark passed when creating this Writable.

    Since

    v9.3.0

  124. val writableLength: Double

    This property contains the number of bytes (or objects) in the queue ready to be written.

    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.

    Since

    v9.4.0

  125. val writableObjectMode: Boolean

    Getter for the property objectMode of a given Writable stream.

    Getter for the property objectMode of a given Writable stream.

    Since

    v12.3.0

  126. def write(chunk: Any, encoding: BufferEncoding, callback: Function1[UndefOr[|[Error, Null]], Unit]): Boolean
  127. def write(chunk: Any, encoding: BufferEncoding): Boolean
  128. def write(chunk: Any, callback: Function1[UndefOr[|[Error, Null]], Unit]): Boolean
  129. def write(chunk: Any): Boolean

    The writable.write() method writes some data to the stream, and calls the supplied callback once the data has been fully handled.

    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 thehighWaterMark 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. It is recommended that once write() returns false, no more chunks be written 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:

    js 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.

    chunk

    Optional data to write. For streams not operating in object mode, chunk must be a string, Buffer or Uint8Array. For object mode streams, chunk may be any JavaScript value other than null.

    returns

    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.

    Since

    v0.9.4

  130. def write(str: String, encoding: Unit, cb: Function1[UndefOr[|[Error, Null]], Unit]): Boolean
    Definition Classes
    WritableStream
  131. def write(str: String, encoding: BufferEncoding, cb: Function1[UndefOr[|[Error, Null]], Unit]): Boolean
    Definition Classes
    WritableStream
  132. def write(str: String, encoding: BufferEncoding): Boolean
    Definition Classes
    WritableStream
  133. def write(buffer: Uint8Array, cb: Function1[UndefOr[|[Error, Null]], Unit]): Boolean
    Definition Classes
    WritableStream
  134. def write(buffer: Uint8Array): Boolean
    Definition Classes
    WritableStream
  135. def write(buffer: String, cb: Function1[UndefOr[|[Error, Null]], Unit]): Boolean
    Definition Classes
    WritableStream
  136. def write(buffer: String): Boolean
    Definition Classes
    WritableStream

Deprecated Value Members

  1. def finalize(): Unit
    Attributes
    protected[lang]
    Definition Classes
    AnyRef
    Annotations
    @throws(classOf[java.lang.Throwable]) @Deprecated
    Deprecated

Inherited from WritableStream

Inherited from EventEmitter

Inherited from StObject

Inherited from Object

Inherited from Any

Inherited from AnyRef

Inherited from Any

Ungrouped