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

Method at

packages/effect/src/Optic.ts:1037–1059  ·  view source on GitHub ↗
(key: PropertyKey, ..._rest: Array<any>)

Source from the content-addressed store, hash-verified

1035 )
1036 }
1037 at(key: PropertyKey, ..._rest: Array<any>): any {
1038 const err = Result.fail(
1039 new SchemaIssue.Pointer([key], new SchemaIssue.MissingKey(undefined))
1040 )
1041 return make(
1042 compose(
1043 this.node,
1044 primitiveNode(
1045 "Optional",
1046 (s) => Object.hasOwn(s, key) ? Result.succeed(s[key]) : err,
1047 (a, s) => {
1048 if (Object.hasOwn(s, key)) {
1049 const copy = cloneShallow(s)
1050 InternalRecord.assignProperty(copy, key, a)
1051 return Result.succeed(copy)
1052 } else {
1053 return err
1054 }
1055 }
1056 )
1057 )
1058 )
1059 }
1060 pick(keys: any) {
1061 return this.compose(makeLens(Struct.pick(keys), (p, a) => ({ ...a, ...p })))
1062 }

Callers

nothing calls this directly

Calls 6

primitiveNodeFunction · 0.85
cloneShallowFunction · 0.85
makeFunction · 0.70
composeFunction · 0.70
failMethod · 0.45
succeedMethod · 0.45

Tested by

no test coverage detected