Share detached JSON provenance with copy checkpoints and finish step-four verification
This commit is contained in:
@@ -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);
|
||||
Reference in New Issue
Block a user