MCPcopy Create free account
hub / github.com/UsefulSoftwareCo/executor / cloneValue

Function cloneValue

packages/core/fumadb/src/adapters/memory/index.ts:15–25  ·  view source on GitHub ↗
(value: T)

Source from the content-addressed store, hash-verified

13}
14
15const cloneValue = <T>(value: T): T => {
16 if (value instanceof Date) return new Date(value.getTime()) as T;
17 if (value instanceof Uint8Array) return new Uint8Array(value) as T;
18 if (Array.isArray(value)) return value.map((item) => cloneValue(item)) as T;
19 if (value && typeof value === "object") {
20 return Object.fromEntries(
21 Object.entries(value).map(([key, item]) => [key, cloneValue(item)])
22 ) as T;
23 }
24 return value;
25};
26
27const comparable = (value: unknown): unknown => {
28 if (value instanceof Date) return value.getTime();

Callers 6

applyDefaultsFunction · 0.85
selectRowFunction · 0.85
updateManyFunction · 0.85
upsertFunction · 0.85
createFunction · 0.85
transactionFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected