(xs, serializer, options, typarray)
| 240 | } |
| 241 | |
| 242 | export const arraySerializer = function arraySerializer(xs, serializer, options, typarray) { |
| 243 | if (Array.isArray(xs) === false) |
| 244 | return xs |
| 245 | |
| 246 | if (!xs.length) |
| 247 | return '{}' |
| 248 | |
| 249 | const first = xs[0] |
| 250 | // Only _box (1020) has the ';' delimiter for arrays, all other types use the ',' delimiter |
| 251 | const delimiter = typarray === 1020 ? ';' : ',' |
| 252 | |
| 253 | if (Array.isArray(first) && !first.type) |
| 254 | return '{' + xs.map(x => arraySerializer(x, serializer, options, typarray)).join(delimiter) + '}' |
| 255 | |
| 256 | return '{' + xs.map(x => { |
| 257 | if (x === undefined) { |
| 258 | x = options.transform.undefined |
| 259 | if (x === undefined) |
| 260 | throw Errors.generic('UNDEFINED_VALUE', 'Undefined values are not allowed') |
| 261 | } |
| 262 | |
| 263 | return x === null |
| 264 | ? 'null' |
| 265 | : '"' + arrayEscape(serializer ? serializer(x.type ? x.value : x) : '' + x) + '"' |
| 266 | }).join(delimiter) + '}' |
| 267 | } |
| 268 | |
| 269 | const arrayParserState = { |
| 270 | i: 0, |
no test coverage detected