Builds a fresh copy of a value that holds only plain JSON types, for handing
to an agent.
Non-finite numbers become null; functions, symbols, bigints, class
instances and cycles are left out; strings pass through clip.
Containers nested deeper than maxDepth are left out, and the copy stops
growing once its JSON would pass maxBytes characters.
Parameters
value: unknown
The value to copy
options: {maxDepth?:number;maxBytes?:number} = {}
The limits
OptionalmaxDepth?: number
Deepest container kept; the root is depth 0
OptionalmaxBytes?: number
Largest JSON length the copy may reach
Returns {value:unknown;truncated:boolean}
The copy, and whether a limit or a clipped string cut anything
Builds a fresh copy of a value that holds only plain JSON types, for handing to an agent.
Non-finite numbers become
null; functions, symbols, bigints, class instances and cycles are left out; strings pass through clip. Containers nested deeper thanmaxDepthare left out, and the copy stops growing once its JSON would passmaxBytescharacters.