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

Function make

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

Source from the content-addressed store, hash-verified

1178}
1179
1180function make(node: Node): any {
1181 let op: Operation = node[0] ?? identityOperation
1182 if (node.length > 1) {
1183 const kind = node.reduce<Kind>((kind, step) => composeKind(kind, step.kind), "Iso")
1184 op = {
1185 kind,
1186 get: compileGet(node, kind),
1187 set: compileSet(node, kind)
1188 }
1189 }
1190 switch (op.kind) {
1191 case "Iso":
1192 return new IsoImpl(node, op.get, op.set)
1193 case "Lens":
1194 return new LensImpl(node, op.get, op.set)
1195 case "Prism":
1196 return new PrismImpl(node, op.get, op.set)
1197 case "Optional":
1198 return new OptionalImpl(node, op.get, op.set)
1199 }
1200}
1201
1202function cloneShallow<T>(pojo: T): T {
1203 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