MCPcopy Index your code
hub / github.com/json5/json5 / serializeArray

Function serializeArray

lib/stringify.js:227–260  ·  view source on GitHub ↗
(value)

Source from the content-addressed store, hash-verified

225 }
226
227 function serializeArray (value) {
228 if (stack.indexOf(value) >= 0) {
229 throw TypeError('Converting circular structure to JSON5')
230 }
231
232 stack.push(value)
233
234 let stepback = indent
235 indent = indent + gap
236
237 let partial = []
238 for (let i = 0; i < value.length; i++) {
239 const propertyString = serializeProperty(String(i), value)
240 partial.push((propertyString !== undefined) ? propertyString : 'null')
241 }
242
243 let final
244 if (partial.length === 0) {
245 final = '[]'
246 } else {
247 if (gap === '') {
248 let properties = partial.join(',')
249 final = '[' + properties + ']'
250 } else {
251 let separator = ',\n' + indent
252 let properties = partial.join(separator)
253 final = '[\n' + indent + properties + ',\n' + stepback + ']'
254 }
255 }
256
257 stack.pop()
258 indent = stepback
259 return final
260 }
261}

Callers 1

serializePropertyFunction · 0.85

Calls 1

serializePropertyFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…