MCPcopy Create free account
hub / github.com/porsager/postgres / data

Function data

cjs/src/connection.js:301–333  ·  view source on GitHub ↗
(x)

Source from the content-addressed store, hash-verified

299 }
300
301 function data(x) {
302 if (incomings) {
303 incomings.push(x)
304 remaining -= x.length
305 if (remaining > 0)
306 return
307 }
308
309 incoming = incomings
310 ? Buffer.concat(incomings, length - remaining)
311 : incoming.length === 0
312 ? x
313 : Buffer.concat([incoming, x], incoming.length + x.length)
314
315 while (incoming.length > 4) {
316 length = incoming.readUInt32BE(1)
317 if (length >= incoming.length) {
318 remaining = length - incoming.length
319 incomings = [incoming]
320 break
321 }
322
323 try {
324 handle(incoming.subarray(0, length + 1))
325 } catch (e) {
326 query && (query.cursorFn || query.describeFirst) && write(Sync)
327 errored(e)
328 }
329 incoming = incoming.subarray(length + 1)
330 remaining = 0
331 incomings = null
332 }
333 }
334
335 async function connect() {
336 terminated = false

Callers

nothing calls this directly

Calls 3

handleFunction · 0.70
writeFunction · 0.70
erroredFunction · 0.70

Tested by

no test coverage detected