MCPcopy Create free account
hub / github.com/Effect-TS/effect / cloneShallow

Function cloneShallow

packages/effect/src/Optic.ts:1187–1197  ·  view source on GitHub ↗
(pojo: T)

Source from the content-addressed store, hash-verified

1185}
1186
1187function cloneShallow<T>(pojo: T): T {
1188 if (Array.isArray(pojo)) return pojo.slice() as T
1189 if (typeof pojo === "object" && pojo !== null) {
1190 const proto = Object.getPrototypeOf(pojo)
1191 if (proto !== Object.prototype && proto !== null) {
1192 throw new Error("Cannot clone object with non-Object constructor or null prototype")
1193 }
1194 return { ...pojo } as T
1195 }
1196 return pojo
1197}
1198
1199function compileGet(nodes: Node, kind: Kind): (s: any) => any {
1200 return (s) => {

Callers 3

constructorMethod · 0.85
optionalKeyMethod · 0.85
atMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected