Detaches the toJSON method from value (if present) and returns a restore function.
This is used by jsonStringify and sanitize to prevent faulty toJSON overrides
from interfering with serialization. The restore function re-attaches the original method.
Parameters
value: object
The object whose toJSON should be detached.
Returns ()=>void
A function that restores the original toJSON (or a no-op if none was present).
Detaches the
toJSONmethod fromvalue(if present) and returns a restore function.This is used by jsonStringify and
sanitizeto prevent faultytoJSONoverrides from interfering with serialization. The restore function re-attaches the original method.