Share detached JSON provenance with copy checkpoints and finish step-four verification

This commit is contained in:
2026-11-11 14:16:45 +08:00
parent 2089b63e79
commit e3a2335160
11 changed files with 149 additions and 48 deletions
+11
View File
@@ -0,0 +1,11 @@
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>();
export function detachJsonData<T>(input:T):T {
const value=freeze(clone(input));
if(value&&typeof value==='object')detached.add(value);
return value;
}
export const hasDetachedJsonData=(value:object)=>detached.has(value);