# Class: Buffer

## vertx-js/buffer~ Buffer

#### new Buffer()

  Most data is shuffled around inside Vert.x using buffers.

  A buffer is a sequence of zero or more bytes that can read from or written to and which expands automatically as necessary to accommodate any bytes written to it. You can perhaps think of a buffer as smart byte array.

  Please consult the documentation for more information on buffers.

  Source:
    - buffer.js, line 34

### Methods

#### appendBuffer(buff, offset, len) → {Buffer}

  Appends the specified `Buffer` starting at the `offset` using `len` to the end of this Buffer. The buffer will expand as necessary to accommodate any bytes written.

  Returns a reference to `this` so multiple operations can be appended together.

  ##### Parameters:

  Name | Type | Description
  --- | --- | ---
  `buff` | Buffer |
  `offset` | number |
  `len` | number |

  Source:
    - buffer.js, line 225

  ##### Returns:

  Type
    Buffer

#### appendByte(b) → {Buffer}

  Appends the specified `byte` to the end of the Buffer. The buffer will expand as necessary to accommodate any bytes written.

  Returns a reference to `this` so multiple operations can be appended together.

  ##### Parameters:

  Name | Type | Description
  --- | --- | ---
  `b` | number |

  Source:
    - buffer.js, line 244

  ##### Returns:

  Type
    Buffer

#### appendDouble(d) → {Buffer}

  Appends the specified `double` to the end of the Buffer. The buffer will expand as necessary to accommodate any bytes written.

  Returns a reference to `this` so multiple operations can be appended together.

  ##### Parameters:

  Name | Type | Description
  --- | --- | ---
  `d` | number |

  Source:
    - buffer.js, line 372

  ##### Returns:

  Type
    Buffer

#### appendFloat(f) → {Buffer}

  Appends the specified `float` to the end of the Buffer. The buffer will expand as necessary to accommodate any bytes written.

  Returns a reference to `this` so multiple operations can be appended together.

  ##### Parameters:

  Name | Type | Description
  --- | --- | ---
  `f` | number |

  Source:
    - buffer.js, line 356

  ##### Returns:

  Type
    Buffer

#### appendInt(i) → {Buffer}

  Appends the specified `int` to the end of the Buffer. The buffer will expand as necessary to accommodate any bytes written.

  Returns a reference to `this` so multiple operations can be appended together.

  ##### Parameters:

  Name | Type | Description
  --- | --- | ---
  `i` | number |

  Source:
    - buffer.js, line 276

  ##### Returns:

  Type
    Buffer

#### appendLong(l) → {Buffer}

  Appends the specified `long` to the end of the Buffer. The buffer will expand as necessary to accommodate any bytes written.

  Returns a reference to `this` so multiple operations can be appended together.

  ##### Parameters:

  Name | Type | Description
  --- | --- | ---
  `l` | number |

  Source:
    - buffer.js, line 308

  ##### Returns:

  Type
    Buffer

#### appendShort(s) → {Buffer}

  Appends the specified `short` to the end of the Buffer.The buffer will expand as necessary to accommodate any bytes written.

  Returns a reference to `this` so multiple operations can be appended together.

  ##### Parameters:

  Name | Type | Description
  --- | --- | ---
  `s` | number |

  Source:
    - buffer.js, line 324

  ##### Returns:

  Type
    Buffer

#### appendString(str, enc) → {Buffer}

  Appends the specified `String` to the end of the Buffer with the encoding as specified by `enc`.

  The buffer will expand as necessary to accommodate any bytes written.

  Returns a reference to `this` so multiple operations can be appended together.

  ##### Parameters:

  Name | Type | Description
  --- | --- | ---
  `str` | string |
  `enc` | string |

  Source:
    - buffer.js, line 390

  ##### Returns:

  Type
    Buffer

#### appendUnsignedByte(b) → {Buffer}

  Appends the specified unsigned `byte` to the end of the Buffer. The buffer will expand as necessary to accommodate any bytes written.

  Returns a reference to `this` so multiple operations can be appended together.

  ##### Parameters:

  Name | Type | Description
  --- | --- | ---
  `b` | number |

  Source:
    - buffer.js, line 260

  ##### Returns:

  Type
    Buffer

#### appendUnsignedInt(i) → {Buffer}

  Appends the specified unsigned `int` to the end of the Buffer. The buffer will expand as necessary to accommodate any bytes written.

  Returns a reference to `this` so multiple operations can be appended together.

  ##### Parameters:

  Name | Type | Description
  --- | --- | ---
  `i` | number |

  Source:
    - buffer.js, line 292

  ##### Returns:

  Type
    Buffer

#### appendUnsignedShort(s) → {Buffer}

  Appends the specified unsigned `short` to the end of the Buffer.The buffer will expand as necessary to accommodate any bytes written.

  Returns a reference to `this` so multiple operations can be appended together.

  ##### Parameters:

  Name | Type | Description
  --- | --- | ---
  `s` | number |

  Source:
    - buffer.js, line 340

  ##### Returns:

  Type
    Buffer

#### copy() → {Buffer}

  Returns a copy of the entire Buffer.
  Source:
    - buffer.js, line 618

  ##### Returns:

  Type
    Buffer

#### getBuffer(start, end) → {Buffer}

  Returns a copy of a sub-sequence the Buffer as a Buffer starting at position `start` and ending at position `end - 1`

  ##### Parameters:

  Name | Type | Description
  --- | --- | ---
  `start` | number |
  `end` | number |

  Source:
    - buffer.js, line 188

  ##### Returns:

  Type
    Buffer

#### getByte(pos) → {number}

  Returns the `byte` at position `pos` in the Buffer.

  ##### Parameters:

  Name | Type | Description
  --- | --- | ---
  `pos` | number |

  Source:
    - buffer.js, line 60

  ##### Returns:

  Type
    number

#### getDouble(pos) → {number}

  Returns the `double` at position `pos` in the Buffer.

  ##### Parameters:

  Name | Type | Description
  --- | --- | ---
  `pos` | number |

  Source:
    - buffer.js, line 130

  ##### Returns:

  Type
    number

#### getFloat(pos) → {number}

  Returns the `float` at position `pos` in the Buffer.

  ##### Parameters:

  Name | Type | Description
  --- | --- | ---
  `pos` | number |

  Source:
    - buffer.js, line 144

  ##### Returns:

  Type
    number

#### getInt(pos) → {number}

  Returns the `int` at position `pos` in the Buffer.

  ##### Parameters:

  Name | Type | Description
  --- | --- | ---
  `pos` | number |

  Source:
    - buffer.js, line 88

  ##### Returns:

  Type
    number

#### getLong(pos) → {number}

  Returns the `long` at position `pos` in the Buffer.

  ##### Parameters:

  Name | Type | Description
  --- | --- | ---
  `pos` | number |

  Source:
    - buffer.js, line 116

  ##### Returns:

  Type
    number

#### getShort(pos) → {number}

  Returns the `short` at position `pos` in the Buffer.

  ##### Parameters:

  Name | Type | Description
  --- | --- | ---
  `pos` | number |

  Source:
    - buffer.js, line 158

  ##### Returns:

  Type
    number

#### getString(start, end, enc) → {string}

  Returns a copy of a sub-sequence the Buffer as a `String` starting at position `start` and ending at position `end - 1` interpreted as a String in the specified encoding

  ##### Parameters:

  Name | Type | Description
  --- | --- | ---
  `start` | number |
  `end` | number |
  `enc` | string |

  Source:
    - buffer.js, line 205

  ##### Returns:

  Type
    string

#### getUnsignedByte(pos) → {number}

  Returns the unsigned `byte` at position `pos` in the Buffer, as a `short`.

  ##### Parameters:

  Name | Type | Description
  --- | --- | ---
  `pos` | number |

  Source:
    - buffer.js, line 74

  ##### Returns:

  Type
    number

#### getUnsignedInt(pos) → {number}

  Returns the unsigned `int` at position `pos` in the Buffer, as a `long`.

  ##### Parameters:

  Name | Type | Description
  --- | --- | ---
  `pos` | number |

  Source:
    - buffer.js, line 102

  ##### Returns:

  Type
    number

#### getUnsignedShort(pos) → {number}

  Returns the unsigned `short` at position `pos` in the Buffer, as an `int`.

  ##### Parameters:

  Name | Type | Description
  --- | --- | ---
  `pos` | number |

  Source:
    - buffer.js, line 172

  ##### Returns:

  Type
    number

#### length() → {number}

  Returns the length of the buffer, measured in bytes. All positions are indexed from zero.
  Source:
    - buffer.js, line 604

  ##### Returns:

  Type
    number

#### setBuffer(pos, b, offset, len) → {Buffer}

  Sets the bytes at position `pos` in the Buffer to the bytes represented by the `Buffer b` on the given `offset` and `len`.

  The buffer will expand as necessary to accommodate any value written.

  ##### Parameters:

  Name | Type | Description
  --- | --- | ---
  `pos` | number |
  `b` | Buffer |
  `offset` | number |
  `len` | number |

  Source:
    - buffer.js, line 564

  ##### Returns:

  Type
    Buffer

#### setByte(pos, b) → {Buffer}

  Sets the `byte` at position `pos` in the Buffer to the value `b`.

  The buffer will expand as necessary to accommodate any value written.

  ##### Parameters:

  Name | Type | Description
  --- | --- | ---
  `pos` | number |
  `b` | number |

  Source:
    - buffer.js, line 410

  ##### Returns:

  Type
    Buffer

#### setDouble(pos, d) → {Buffer}

  Sets the `double` at position `pos` in the Buffer to the value `d`.

  The buffer will expand as necessary to accommodate any value written.

  ##### Parameters:

  Name | Type | Description
  --- | --- | ---
  `pos` | number |
  `d` | number |

  Source:
    - buffer.js, line 494

  ##### Returns:

  Type
    Buffer

#### setFloat(pos, f) → {Buffer}

  Sets the `float` at position `pos` in the Buffer to the value `f`.

  The buffer will expand as necessary to accommodate any value written.

  ##### Parameters:

  Name | Type | Description
  --- | --- | ---
  `pos` | number |
  `f` | number |

  Source:
    - buffer.js, line 511

  ##### Returns:

  Type
    Buffer

#### setInt(pos, i) → {Buffer}

  Sets the `int` at position `pos` in the Buffer to the value `i`.

  The buffer will expand as necessary to accommodate any value written.

  ##### Parameters:

  Name | Type | Description
  --- | --- | ---
  `pos` | number |
  `i` | number |

  Source:
    - buffer.js, line 443

  ##### Returns:

  Type
    Buffer

#### setLong(pos, l) → {Buffer}

  Sets the `long` at position `pos` in the Buffer to the value `l`.

  The buffer will expand as necessary to accommodate any value written.

  ##### Parameters:

  Name | Type | Description
  --- | --- | ---
  `pos` | number |
  `l` | number |

  Source:
    - buffer.js, line 477

  ##### Returns:

  Type
    Buffer

#### setShort(pos, s) → {Buffer}

  Sets the `short` at position `pos` in the Buffer to the value `s`.

  The buffer will expand as necessary to accommodate any value written.

  ##### Parameters:

  Name | Type | Description
  --- | --- | ---
  `pos` | number |
  `s` | number |

  Source:
    - buffer.js, line 528

  ##### Returns:

  Type
    Buffer

#### setString(pos, str, enc) → {Buffer}

  Sets the bytes at position `pos` in the Buffer to the value of `str` encoded in encoding `enc`.

  The buffer will expand as necessary to accommodate any value written.

  ##### Parameters:

  Name | Type | Description
  --- | --- | ---
  `pos` | number |
  `str` | string |
  `enc` | string |

  Source:
    - buffer.js, line 585

  ##### Returns:

  Type
    Buffer

#### setUnsignedByte(pos, b) → {Buffer}

  Sets the unsigned `byte` at position `pos` in the Buffer to the value `b`.

  The buffer will expand as necessary to accommodate any value written.

  ##### Parameters:

  Name | Type | Description
  --- | --- | ---
  `pos` | number |
  `b` | number |

  Source:
    - buffer.js, line 427

  ##### Returns:

  Type
    Buffer

#### setUnsignedInt(pos, i) → {Buffer}

  Sets the unsigned `int` at position `pos` in the Buffer to the value `i`.

  The buffer will expand as necessary to accommodate any value written.

  ##### Parameters:

  Name | Type | Description
  --- | --- | ---
  `pos` | number |
  `i` | number |

  Source:
    - buffer.js, line 460

  ##### Returns:

  Type
    Buffer

#### setUnsignedShort(pos, s) → {Buffer}

  Sets the unsigned `short` at position `pos` in the Buffer to the value `s`.

  The buffer will expand as necessary to accommodate any value written.

  ##### Parameters:

  Name | Type | Description
  --- | --- | ---
  `pos` | number |
  `s` | number |

  Source:
    - buffer.js, line 545

  ##### Returns:

  Type
    Buffer

#### slice(start, end) → {Buffer}

  Returns a slice of this buffer. Modifying the content of the returned buffer or this buffer affects each other's content while they maintain separate indexes and marks.

  ##### Parameters:

  Name | Type | Description
  --- | --- | ---
  `start` | number |
  `end` | number |

  Source:
    - buffer.js, line 635

  ##### Returns:

  Type
    Buffer

#### toString(enc) → {string}

  Returns a `String` representation of the Buffer with the encoding specified by `enc`

  ##### Parameters:

  Name | Type | Description
  --- | --- | ---
  `enc` | string |

  Source:
    - buffer.js, line 46

  ##### Returns:

  Type
    string