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

Function encodeArgs

packages/effect/src/ui/MessageLog.ts:2124–2143  ·  view source on GitHub ↗
(schema: Schema.Top, value: unknown)

Source from the content-addressed store, hash-verified

2122 * @internal
2123 */
2124export const encodeArgs = (schema: Schema.Top, value: unknown): Schema.Json => {
2125 const walk: Walk = { path: new Set(), strict: false, leaf: fallback }
2126 // A struct or a class is encoded field by field.
2127 const fields = (schema as { readonly fields?: Schema.Struct.Fields }).fields
2128 if (fields !== undefined && isPlainRecord(value)) {
2129 return within(walk.path, value, () => {
2130 const out: Record<string, Schema.Json> = {}
2131 for (const key of Object.keys(fields)) {
2132 if (!Object.hasOwn(value, key)) continue
2133 InternalRecord.assignProperty(
2134 out,
2135 key,
2136 guarded(() => encodeAt((fields[key] as Schema.Top).ast, value[key], walk))
2137 )
2138 }
2139 return out
2140 })
2141 }
2142 return guarded(() => encodeAt(schema.ast, value, walk))
2143}
2144
2145const encodeCause = (cause: Cause.Cause<unknown>): typeof CauseWire.Type => ({
2146 pretty: Cause.pretty(cause),

Callers 7

encodeFunction · 0.85
encodeSourceFunction · 0.85
encodeCommandFunction · 0.85
encodeGroupFunction · 0.85
encodeSendFunction · 0.85
argsKeyFunction · 0.85
toKeyFunction · 0.85

Calls 5

encodeAtFunction · 0.85
keysMethod · 0.80
isPlainRecordFunction · 0.70
withinFunction · 0.70
guardedFunction · 0.70

Tested by

no test coverage detected