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

Function make

packages/effect/src/Optic.ts:1165–1185  ·  view source on GitHub ↗
(node: Node)

Source from the content-addressed store, hash-verified

1163}
1164
1165function make(node: Node): any {
1166 let op: Operation = node[0] ?? identityOperation
1167 if (node.length > 1) {
1168 const kind = node.reduce<Kind>((kind, step) => composeKind(kind, step.kind), "Iso")
1169 op = {
1170 kind,
1171 get: compileGet(node, kind),
1172 set: compileSet(node, kind)
1173 }
1174 }
1175 switch (op.kind) {
1176 case "Iso":
1177 return new IsoImpl(node, op.get, op.set)
1178 case "Lens":
1179 return new LensImpl(node, op.get, op.set)
1180 case "Prism":
1181 return new PrismImpl(node, op.get, op.set)
1182 case "Optional":
1183 return new OptionalImpl(node, op.get, op.set)
1184 }
1185}
1186
1187function cloneShallow<T>(pojo: T): T {
1188 if (Array.isArray(pojo)) return pojo.slice() as T

Callers 14

makeIsoFunction · 0.70
makeLensFunction · 0.70
makePrismFunction · 0.70
fromChecksFunction · 0.70
makeOptionalFunction · 0.70
composeMethod · 0.70
keyMethod · 0.70
optionalKeyMethod · 0.70
checkMethod · 0.70
refineMethod · 0.70
tagMethod · 0.70
atMethod · 0.70

Calls 3

composeKindFunction · 0.85
compileGetFunction · 0.85
compileSetFunction · 0.85

Tested by

no test coverage detected