docs(core): clarify capture validation and replay guarantees
This commit is contained in:
@@ -7,8 +7,9 @@ import {clone,freeze} from './values.ts';
|
||||
// Private provenance for a fresh, recursively frozen JSON clone. A caller can
|
||||
// request a detached copy, but cannot grant this fact to an existing object.
|
||||
const detached=new WeakSet<object>();
|
||||
/** JSON 复制后递归冻结;对象结果记录到 WeakSet,原始值直接返回。
|
||||
* clone 会按 JSON 规则处理数据,所以不可用它代替迁移输入的严格捕获校验。 */
|
||||
/** JSON 复制后递归冻结;仅对象结果记录到 WeakSet。
|
||||
* 输入先经过 JSON 序列化语义:toJSON/getter 可能执行,稀疏槽/数组中的非法 JSON 值可能转为 null。
|
||||
* 循环或 BigInt 等仍会抛错;它不保留任意输入原貌,不能替代迁移输入的严格捕获校验。 */
|
||||
export function detachJsonData<T>(input:T):T {
|
||||
const value=freeze(clone(input));
|
||||
if(value&&typeof value==='object')detached.add(value);
|
||||
|
||||
Reference in New Issue
Block a user