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

Function tuples

cjs/src/subscribe.js:234–264  ·  view source on GitHub ↗
(x, columns, xi, transform)

Source from the content-addressed store, hash-verified

232}
233
234function tuples(x, columns, xi, transform) {
235 let type
236 , column
237 , value
238
239 const row = transform.raw ? new Array(columns.length) : {}
240 for (let i = 0; i < columns.length; i++) {
241 type = x[xi++]
242 column = columns[i]
243 value = type === 110 // n
244 ? null
245 : type === 117 // u
246 ? undefined
247 : column.parser === undefined
248 ? x.toString('utf8', xi + 4, xi += 4 + x.readUInt32BE(xi))
249 : column.parser.array === true
250 ? column.parser(x.toString('utf8', xi + 5, xi += 4 + x.readUInt32BE(xi)))
251 : column.parser(x.toString('utf8', xi + 4, xi += 4 + x.readUInt32BE(xi)))
252
253 transform.raw
254 ? (row[i] = transform.raw === true
255 ? value
256 : transform.value.from ? transform.value.from(value, column) : value)
257 : (row[column.name] = transform.value.from
258 ? transform.value.from(value, column)
259 : value
260 )
261 }
262
263 return { i: xi, row: transform.row.from ? transform.row.from(row) : row }
264}
265
266function parseEvent(x) {
267 const xs = x.match(/^(\*|insert|update|delete)?:?([^.]+?\.?[^=]+)?=?(.+)?/i) || []

Callers 1

parseFunction · 0.70

Calls 1

parserMethod · 0.65

Tested by

no test coverage detected