_ensureCapacity()

in src/internal/MessageBuffer.ts [284:299]


    _ensureCapacity(valueSize) {
        if (valueSize <= 0) {
            throw IgniteClientError.internalError();
        }
        let newCapacity = this._capacity;
        while (this._position + valueSize > newCapacity) {
            newCapacity = newCapacity * 2;
        }
        if (this._capacity < newCapacity) {
            this._buffer = Buffer.concat([this._buffer, Buffer.allocUnsafe(newCapacity - this._capacity)], newCapacity);
            this._capacity = newCapacity;
        }
        if (this._position + valueSize > this._length) {
            this._length = this._position + valueSize;
        }
    }