MCPcopy Create free account
hub / github.com/apache/maka / cloneAndFreezeSnapshotValue

Function cloneAndFreezeSnapshotValue

packages/runtime/src/runtime-runner.ts:571–589  ·  view source on GitHub ↗
(value: T)

Source from the content-addressed store, hash-verified

569}
570
571function cloneAndFreezeSnapshotValue<T>(value: T): T {
572 if (Array.isArray(value)) {
573 return Object.freeze(value.map((item) => cloneAndFreezeSnapshotValue(item))) as T;
574 }
575 if (value && typeof value === 'object') {
576 const prototype = Object.getPrototypeOf(value);
577 if (prototype !== Object.prototype && prototype !== null) return value;
578 const clone: Record<string, unknown> = Object.create(prototype);
579 for (const key of Object.keys(value)) {
580 const descriptor = Object.getOwnPropertyDescriptor(value, key);
581 if (!descriptor || !('value' in descriptor)) {
582 throw new Error(`Invocation snapshot rejects accessor property ${key}`);
583 }
584 clone[key] = cloneAndFreezeSnapshotValue(descriptor.value);
585 }
586 return Object.freeze(clone) as T;
587 }
588 return value;
589}
590
591function invocationContinuationMetadata(
592 continuation: RuntimeContinuation,

Callers 1

Calls 2

keysMethod · 0.80
createMethod · 0.65

Tested by

no test coverage detected