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