MCPcopy Index your code
hub / github.com/Effect-TS/effect / optionalField

Function optionalField

packages/opentelemetry/src/internal/protobuf.ts:208–211  ·  view source on GitHub ↗
(
  value: T | undefined,
  encode: (v: T) => Uint8Array
)

Source from the content-addressed store, hash-verified

206 * Helper to conditionally encode an optional field
207 */
208export const optionalField = <T>(
209 value: T | undefined,
210 encode: (v: T) => Uint8Array
211): Uint8Array => value !== undefined ? encode(value) : new Uint8Array(0)
212
213/**
214 * Helper to conditionally encode a string field if non-empty

Callers

nothing calls this directly

Calls 1

encodeFunction · 0.50

Tested by

no test coverage detected