MCPcopy Create free account
hub / github.com/apache/maka / serializedByteLength

Function serializedByteLength

packages/code-mode/src/index.ts:10–20  ·  view source on GitHub ↗
(value: unknown, maxBytes = Number.POSITIVE_INFINITY)

Source from the content-addressed store, hash-verified

8 * returned to the cell, including quotes and escapes for strings.
9 */
10export 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
22interface SerializedByteBudget {
23 bytes: number;

Callers 2

executeToolMethod · 0.90
code-mode.test.tsFile · 0.50

Calls 1

countSerializedValueFunction · 0.85

Tested by

no test coverage detected