MCPcopy Create free account
hub / github.com/chronoxor/FastBinaryEncoding / reserve

Method reserve

projects/JavaScript/proto/fbe.js:292–302  ·  view source on GitHub ↗

* Reserve memory of the given capacity in the current write buffer * @this {!WriteBuffer} * @param {number} capacity Write buffer capacity

(capacity)

Source from the content-addressed store, hash-verified

290 * @param {number} capacity Write buffer capacity
291 */
292 reserve (capacity) {
293 if (capacity < 0) {
294 throw new Error('Invalid reserve capacity!')
295 }
296
297 if (capacity > this._buffer.length) {
298 let data = new Uint8Array(Math.max(capacity, 2 * this._buffer.length))
299 data.set(this._buffer)
300 this._buffer = data
301 }
302 }
303
304 /**
305 * Resize the current write buffer

Callers 1

resizeMethod · 0.95

Calls 1

setMethod · 0.45

Tested by

no test coverage detected