MCPcopy Index your code
hub / github.com/brianc/node-postgres / ensure

Method ensure

packages/pg-protocol/src/buffer-writer.ts:11–21  ·  view source on GitHub ↗
(size: number)

Source from the content-addressed store, hash-verified

9 }
10
11 private ensure(size: number): void {
12 const remaining = this.buffer.length - this.offset
13 if (remaining < size) {
14 const oldBuffer = this.buffer
15 // exponential growth factor of around ~ 1.5
16 // https://stackoverflow.com/questions/2269063/buffer-growth-strategy
17 const newSize = oldBuffer.length + (oldBuffer.length >> 1) + size
18 this.buffer = Buffer.allocUnsafe(newSize)
19 oldBuffer.copy(this.buffer)
20 }
21 }
22
23 public addInt32(num: number): Writer {
24 this.ensure(4)

Callers 6

addInt32Method · 0.95
addInt16Method · 0.95
addCStringMethod · 0.95
addStringMethod · 0.95
addMethod · 0.95

Calls

no outgoing calls

Tested by

no test coverage detected