MCPcopy Create free account
hub / github.com/effect-app/libs / optionalOption

Function optionalOption

packages/infra/src/SQL/Model.ts:261–270  ·  view source on GitHub ↗
(schema: S)

Source from the content-addressed store, hash-verified

259 * @category optional
260 */
261export const optionalOption = <S extends Schema.Top>(schema: S): optionalOption<S> =>
262 Schema.optionalKey(Schema.NullOr(schema)).pipe(
263 Schema.decodeTo(
264 Schema.Option(Schema.toType(schema)),
265 Transformation.transformOptional<Option.Option<S["Type"]>, S["Type"] | null>({
266 decode: (oe) => oe.pipe(Option.filter(Predicate.isNotNull), Option.some),
267 encode: Option.flatten
268 }) as any
269 )
270 )
271
272/**
273 * Convert a field to one that is optional for all variants.

Callers

nothing calls this directly

Calls 3

filterMethod · 0.80
pipeMethod · 0.65
optionalKeyMethod · 0.65

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…