(item)
| 467 | * @returns {string} stack |
| 468 | */ |
| 469 | const stackToString = (item) => { |
| 470 | const arr = [...cycleStack]; |
| 471 | arr.push(item); |
| 472 | return arr |
| 473 | .map((item) => { |
| 474 | if (typeof item === "string") { |
| 475 | if (item.length > 100) { |
| 476 | return `String ${JSON.stringify(item.slice(0, 100)).slice( |
| 477 | 0, |
| 478 | -1 |
| 479 | )}..."`; |
| 480 | } |
| 481 | return `String ${JSON.stringify(item)}`; |
| 482 | } |
| 483 | try { |
| 484 | const { request, name } = ObjectMiddleware.getSerializerFor(item); |
| 485 | if (request) { |
| 486 | return `${request}${name ? `.${name}` : ""}`; |
| 487 | } |
| 488 | } catch (_err) { |
| 489 | // ignore -> fallback |
| 490 | } |
| 491 | if (typeof item === "object" && item !== null) { |
| 492 | if (item.constructor) { |
| 493 | if (item.constructor === Object) { |
| 494 | return `Object { ${Object.keys(item).join(", ")} }`; |
| 495 | } |
| 496 | if (item.constructor === Map) { |
| 497 | return `Map { ${/** @type {Map<EXPECTED_ANY, EXPECTED_ANY>} */ (item).size} items }`; |
| 498 | } |
| 499 | if (item.constructor === Array) { |
| 500 | return `Array { ${/** @type {EXPECTED_ANY[]} */ (item).length} items }`; |
| 501 | } |
| 502 | if (item.constructor === Set) { |
| 503 | return `Set { ${/** @type {Set<EXPECTED_ANY>} */ (item).size} items }`; |
| 504 | } |
| 505 | if (item.constructor === RegExp) { |
| 506 | return /** @type {RegExp} */ (item).toString(); |
| 507 | } |
| 508 | return `${item.constructor.name}`; |
| 509 | } |
| 510 | return `Object [null prototype] { ${Object.keys(item).join( |
| 511 | ", " |
| 512 | )} }`; |
| 513 | } |
| 514 | if (typeof item === "bigint") { |
| 515 | return `BigInt ${item}n`; |
| 516 | } |
| 517 | try { |
| 518 | return `${item}`; |
| 519 | } catch (err) { |
| 520 | return `(${/** @type {Error} */ (err).message})`; |
| 521 | } |
| 522 | }) |
| 523 | .join(" -> "); |
| 524 | }; |
| 525 | /** @type {undefined | WeakSet<Error>} */ |
| 526 | let hasDebugInfoAttached; |
nothing calls this directly
no test coverage detected