(value: unknown, maxBytes = Number.POSITIVE_INFINITY)
| 8 | * returned to the cell, including quotes and escapes for strings. |
| 9 | */ |
| 10 | export function serializedByteLength(value: unknown, maxBytes = Number.POSITIVE_INFINITY): number { |
| 11 | const limit = |
| 12 | Number.isFinite(maxBytes) && maxBytes >= 0 ? Math.floor(maxBytes) : Number.POSITIVE_INFINITY; |
| 13 | const budget: SerializedByteBudget = { bytes: 0, limit, seen: new Set() }; |
| 14 | try { |
| 15 | if (!countSerializedValue(value, budget, 'top')) return Number.POSITIVE_INFINITY; |
| 16 | } catch { |
| 17 | return Number.POSITIVE_INFINITY; |
| 18 | } |
| 19 | return budget.bytes; |
| 20 | } |
| 21 | |
| 22 | interface SerializedByteBudget { |
| 23 | bytes: number; |
no test coverage detected