# Class: WriteStream

## vertx-js/write_stream~ WriteStream

#### new WriteStream()

Represents a stream of data that can be written to.

Source:
  - vertx-js/write_stream.js, line 31

### Methods

#### drainHandler(handler) → {WriteStream}

Set a drain handler on the stream. If the write queue is full, then the handler will be called when the write queue has been reduced to maxSize / 2. See Pump for an example of this being used.

##### Parameters:

Name | Type | Description
--- | --- | ---
`handler` | function | the handler

Source:
  - vertx-js/write_stream.js, line 125

##### Returns:

a reference to this, so the API can be used fluently

Type
  WriteStream

#### end(t)

Same as WriteStream#end but writes some data to the stream before ending.

##### Parameters:

Name | Type | Description
--- | --- | ---
`t` | Object |

Source:
  - vertx-js/write_stream.js, line 77

#### exceptionHandler(handler) → {WriteStream}

Set an exception handler on the write stream.

##### Parameters:

Name | Type | Description
--- | --- | ---
`handler` | function | the exception handler

Source:
  - vertx-js/write_stream.js, line 44

##### Returns:

a reference to this, so the API can be used fluently

Type
  WriteStream

#### setWriteQueueMaxSize(maxSize) → {WriteStream}

Set the maximum size of the write queue to `maxSize`. You will still be able to write to the stream even if there is more than `maxSize` bytes in the write queue. This is used as an indicator by classes such as `Pump` to provide flow control.

##### Parameters:

Name | Type | Description
--- | --- | ---
`maxSize` | number | the max size of the write stream

Source:
  - vertx-js/write_stream.js, line 95

##### Returns:

a reference to this, so the API can be used fluently

Type
  WriteStream

#### write(data) → {WriteStream}

Write some data to the stream. The data is put on an internal write queue, and the write actually happens asynchronously. To avoid running out of memory by putting too much on the write queue, check the WriteStream#writeQueueFull method before writing. This is done automatically if using a Pump.

##### Parameters:

Name | Type | Description
--- | --- | ---
`data` | Object | the data to write

Source:
  - vertx-js/write_stream.js, line 63

##### Returns:

a reference to this, so the API can be used fluently

Type
  WriteStream

#### writeQueueFull() → {boolean}

This will return `true` if there are more bytes in the write queue than the value set using WriteStream#setWriteQueueMaxSize

Source:
  - vertx-js/write_stream.js, line 110

##### Returns:

true if write queue is full

Type
  boolean