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

Function arrayParserLoop

cf/src/types.js:282–317  ·  view source on GitHub ↗
(s, x, parser, typarray)

Source from the content-addressed store, hash-verified

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

Callers 1

arrayParserFunction · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected