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:

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:
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:
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:
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:
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:
Returns:
Type
Buffer

appendIntLE(i) → {Buffer}

Appends the specified int to the end of the Buffer in the Little Endian Byte Order. 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:
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:
Returns:
Type
Buffer

appendLongLE(l) → {Buffer}

Appends the specified long to the end of the Buffer in the Little Endian Byte Order. 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:
Returns:
Type
Buffer

appendMedium(i) → {Buffer}

Appends the specified 24bit 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:
Returns:
Type
Buffer

appendMediumLE(i) → {Buffer}

Appends the specified 24bit int to the end of the Buffer in the Little Endian Byte Order. 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:
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:
Returns:
Type
Buffer

appendShortLE(s) → {Buffer}

Appends the specified short to the end of the Buffer in the Little Endian Byte Order.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:
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:
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:
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:
Returns:
Type
Buffer

appendUnsignedIntLE(i) → {Buffer}

Appends the specified unsigned int to the end of the Buffer in the Little Endian Byte Order. 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:
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:
Returns:
Type
Buffer

appendUnsignedShortLE(s) → {Buffer}

Appends the specified unsigned short to the end of the Buffer in the Little Endian Byte Order.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:
Returns:
Type
Buffer

copy() → {Buffer}

Returns a copy of the entire Buffer.
Source:
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:
Returns:
Type
Buffer

getByte(pos) → {number}

Returns the byte at position pos in the Buffer.
Parameters:
Name Type Description
pos number
Source:
Returns:
Type
number

getDouble(pos) → {number}

Returns the double at position pos in the Buffer.
Parameters:
Name Type Description
pos number
Source:
Returns:
Type
number

getFloat(pos) → {number}

Returns the float at position pos in the Buffer.
Parameters:
Name Type Description
pos number
Source:
Returns:
Type
number

getInt(pos) → {number}

Returns the int at position pos in the Buffer.
Parameters:
Name Type Description
pos number
Source:
Returns:
Type
number

getIntLE(pos) → {number}

Gets a 32-bit integer at the specified absolute index in this buffer with Little Endian Byte Order.
Parameters:
Name Type Description
pos number
Source:
Returns:
Type
number

getLong(pos) → {number}

Returns the long at position pos in the Buffer.
Parameters:
Name Type Description
pos number
Source:
Returns:
Type
number

getLongLE(pos) → {number}

Gets a 64-bit long integer at the specified absolute index in this buffer in Little Endian Byte Order.
Parameters:
Name Type Description
pos number
Source:
Returns:
Type
number

getMedium(pos) → {number}

Gets a 24-bit medium integer at the specified absolute index in this buffer.
Parameters:
Name Type Description
pos number
Source:
Returns:
Type
number

getMediumLE(pos) → {number}

Gets a 24-bit medium integer at the specified absolute index in this buffer in the Little Endian Byte Order.
Parameters:
Name Type Description
pos number
Source:
Returns:
Type
number

getShort(pos) → {number}

Returns the short at position pos in the Buffer.
Parameters:
Name Type Description
pos number
Source:
Returns:
Type
number

getShortLE(pos) → {number}

Gets a 16-bit short integer at the specified absolute index in this buffer in Little Endian Byte Order.
Parameters:
Name Type Description
pos number
Source:
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:
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:
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:
Returns:
Type
number

getUnsignedIntLE(pos) → {number}

Returns the unsigned int at position pos in the Buffer, as a long in Little Endian Byte Order.
Parameters:
Name Type Description
pos number
Source:
Returns:
Type
number

getUnsignedMedium(pos) → {number}

Gets an unsigned 24-bit medium integer at the specified absolute index in this buffer.
Parameters:
Name Type Description
pos number
Source:
Returns:
Type
number

getUnsignedMediumLE(pos) → {number}

Gets an unsigned 24-bit medium integer at the specified absolute index in this buffer in Little Endian Byte Order.
Parameters:
Name Type Description
pos number
Source:
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:
Returns:
Type
number

getUnsignedShortLE(pos) → {number}

Gets an unsigned 16-bit short integer at the specified absolute index in this buffer in Little Endian Byte Order.
Parameters:
Name Type Description
pos number
Source:
Returns:
Type
number

length() → {number}

Returns the length of the buffer, measured in bytes. All positions are indexed from zero.
Source:
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:
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:
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:
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:
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:
Returns:
Type
Buffer

setIntLE(pos, i) → {Buffer}

Sets the int at position pos in the Buffer to the value i in the Little Endian Byte Order.

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

Parameters:
Name Type Description
pos number
i number
Source:
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:
Returns:
Type
Buffer

setLongLE(pos, l) → {Buffer}

Sets the long at position pos in the Buffer to the value l in the Little Endian Byte Order.

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

Parameters:
Name Type Description
pos number
l number
Source:
Returns:
Type
Buffer

setMedium(pos, i) → {Buffer}

Sets the 24bit 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:
Returns:
Type
Buffer

setMediumLE(pos, i) → {Buffer}

Sets the 24bit int at position pos in the Buffer to the value i. in the Little Endian Byte Order

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

Parameters:
Name Type Description
pos number
i number
Source:
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:
Returns:
Type
Buffer

setShortLE(pos, s) → {Buffer}

Sets the short at position pos in the Buffer to the value s in the Little Endian Byte Order.

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

Parameters:
Name Type Description
pos number
s number
Source:
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:
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:
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:
Returns:
Type
Buffer

setUnsignedIntLE(pos, i) → {Buffer}

Sets the unsigned int at position pos in the Buffer to the value i in the Little Endian Byte Order.

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

Parameters:
Name Type Description
pos number
i number
Source:
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:
Returns:
Type
Buffer

setUnsignedShortLE(pos, s) → {Buffer}

Sets the unsigned short at position pos in the Buffer to the value s in the Little Endian Byte Order.

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

Parameters:
Name Type Description
pos number
s number
Source:
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:
Returns:
Type
Buffer

toJsonArray() → {todo}

Returns a Json array representation of the Buffer
Source:
Returns:
Type
todo

toJsonObject() → {Object}

Returns a Json object representation of the Buffer
Source:
Returns:
Type
Object

toString(enc) → {string}

Returns a String representation of the Buffer with the encoding specified by enc
Parameters:
Name Type Description
enc string
Source:
Returns:
Type
string