(part)
| 335 | } |
| 336 | |
| 337 | function unionSortKey(part) { |
| 338 | const text = part.trim(); |
| 339 | const primitiveOrder = new Map([ |
| 340 | ['any', 0], |
| 341 | ['unknown', 1], |
| 342 | ['never', 2], |
| 343 | ['void', 3], |
| 344 | ['boolean', 4], |
| 345 | ['number', 5], |
| 346 | ['string', 6], |
| 347 | ['symbol', 7], |
| 348 | ['bigint', 8] |
| 349 | ]); |
| 350 | |
| 351 | if (primitiveOrder.has(text)) { |
| 352 | return [0, primitiveOrder.get(text), '']; |
| 353 | } |
| 354 | |
| 355 | if (/^-?\d+(?:\.\d+)?$/.test(text)) { |
| 356 | return [1, Number(text), '']; |
| 357 | } |
| 358 | |
| 359 | const literal = stringLiteralValue(text); |
| 360 | if (literal != null) { |
| 361 | const booleanLiteralOrder = new Map([ |
| 362 | ['true', 0], |
| 363 | ['false', 1] |
| 364 | ]); |
| 365 | if (booleanLiteralOrder.has(literal)) { |
| 366 | return [2, booleanLiteralOrder.get(literal), literal]; |
| 367 | } |
| 368 | return [2, 2, literal.toLowerCase()]; |
| 369 | } |
| 370 | |
| 371 | if (text === 'null') { |
| 372 | return [8, 0, '']; |
| 373 | } |
| 374 | |
| 375 | if (text === 'undefined') { |
| 376 | return [9, 0, '']; |
| 377 | } |
| 378 | |
| 379 | return [3, 0, text.toLowerCase()]; |
| 380 | } |
| 381 | |
| 382 | function compareUnionParts(a, b) { |
| 383 | const aKey = unionSortKey(a); |
no test coverage detected