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

Function arrayParserLoop

cjs/src/types.js:281–316  ·  view source on GitHub ↗
(s, x, parser, typarray)

Source from the content-addressed store, hash-verified

279}
280
281function arrayParserLoop(s, x, parser, typarray) {
282 const xs = []
283 // Only _box (1020) has the ';' delimiter for arrays, all other types use the ',' delimiter
284 const delimiter = typarray === 1020 ? ';' : ','
285 for (; s.i < x.length; s.i++) {
286 s.char = x[s.i]
287 if (s.quoted) {
288 if (s.char === '\\') {
289 s.str += x[++s.i]
290 } else if (s.char === '"') {
291 xs.push(parser ? parser(s.str) : s.str)
292 s.str = ''
293 s.quoted = x[s.i + 1] === '"'
294 s.last = s.i + 2
295 } else {
296 s.str += s.char
297 }
298 } else if (s.char === '"') {
299 s.quoted = true
300 } else if (s.char === '{') {
301 s.last = ++s.i
302 xs.push(arrayParserLoop(s, x, parser, typarray))
303 } else if (s.char === '}') {
304 s.quoted = false
305 s.last < s.i && xs.push(parser ? parser(x.slice(s.last, s.i)) : x.slice(s.last, s.i))
306 s.last = s.i + 1
307 break
308 } else if (s.char === delimiter && s.p !== '}' && s.p !== '"') {
309 xs.push(parser ? parser(x.slice(s.last, s.i)) : x.slice(s.last, s.i))
310 s.last = s.i + 1
311 }
312 s.p = s.char
313 }
314 s.last < s.i && xs.push(parser ? parser(x.slice(s.last, s.i + 1)) : x.slice(s.last, s.i + 1))
315 return xs
316}
317
318const toCamel = module.exports.toCamel = x => {
319 let str = x[0]

Callers 1

types.jsFile · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected