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

Function checkEffect

packages/effect/src/SchemaGetter.ts:467–482  ·  view source on GitHub ↗
(
  f: (input: T, options: SchemaAST.ParseOptions) => Effect.Effect<
    undefined | boolean | Schema.FilterIssue,
    never,
    R
  >
)

Source from the content-addressed store, hash-verified

465 * @since 4.0.0
466 */
467export function checkEffect<T, R = never>(
468 f: (input: T, options: SchemaAST.ParseOptions) => Effect.Effect<
469 undefined | boolean | Schema.FilterIssue,
470 never,
471 R
472 >
473): Getter<T, T, R> {
474 return onSome((t, options) => {
475 return f(t, options).pipe(Effect.flatMapEager((out) => {
476 const issue = SchemaIssue.makeSingle(out, t, options)
477 return issue ?
478 Effect.fail(issue) :
479 Effect.succeed(Option.some(t))
480 }))
481 })
482}
483
484/**
485 * Creates a getter that applies a pure function to present values.

Callers

nothing calls this directly

Calls 6

someMethod · 0.80
onSomeFunction · 0.70
pipeMethod · 0.65
fFunction · 0.50
failMethod · 0.45
succeedMethod · 0.45

Tested by

no test coverage detected