Class: DynamicBuffer

DynamicBuffer

new DynamicBuffer(length)

Create a DynamicBuffer where this.array is a Buffer of size length. To access the array, use this.array or call slice.
Parameters:
Name Type Description
length number the initial length of the array. If null, use a default.
Source:

Methods

copy(value, offset) → {number}

Copy the value to this.array at offset, reallocating if necessary.
Parameters:
Name Type Description
value Buffer The buffer to copy.
offset number The offset in the buffer to start copying into.
Source:
Returns:
The new offset which is offset + value.length.
Type
number

copyFromBack(value, offsetFromBack)

First call ensureLengthFromBack to make sure the bytearray has offsetFromBack bytes, then copy value into the array starting offsetFromBack bytes from the back of the array.
Parameters:
Name Type Description
value Buffer The buffer to copy.
offsetFromBack number The offset from the back of the array to start copying.
Source:

ensureLength(length)

Ensure that this.array has the length, reallocate and copy if necessary. Update the length of this.array which may be greater than length.
Parameters:
Name Type Description
length number The minimum length for the array.
Source:

ensureLengthFromBack(length)

Ensure that this.array has the length. If necessary, reallocate the array and shift existing data to the back of the new array. Update the length of this.array which may be greater than length.
Parameters:
Name Type Description
length number The minimum length for the array.
Source:

slice(begin, end) → {Buffer}

Return this.array.slice(begin, end);
Parameters:
Name Type Description
begin number The begin index for the slice.
end number (optional) The end index for the slice.
Source:
Returns:
The buffer slice.
Type
Buffer