MCPcopy
hub / github.com/brianc/node-postgres / cstringMessage

Function cstringMessage

packages/pg-protocol/src/serializer.ts:216–226  ·  view source on GitHub ↗
(code: code, string: string)

Source from the content-addressed store, hash-verified

214}
215
216const cstringMessage = (code: code, string: string): Buffer => {
217 const stringLen = Buffer.byteLength(string)
218 const len = 4 + stringLen + 1
219 // one extra bit for code
220 const buffer = Buffer.allocUnsafe(1 + len)
221 buffer[0] = code
222 buffer.writeInt32BE(len, 1)
223 buffer.write(string, 5, 'utf-8')
224 buffer[len] = 0 // null terminate cString
225 return buffer
226}
227
228const emptyDescribePortal = writer.addCString('P').flush(code.describe)
229const emptyDescribeStatement = writer.addCString('S').flush(code.describe)

Callers 3

describeFunction · 0.85
closeFunction · 0.85
copyFailFunction · 0.85

Calls 1

writeMethod · 0.80

Tested by 1

describeFunction · 0.68