Alternative selection
anyfunction
Runs candidates sequentially and returns the first match tagged with its key. Candidates are snapshotted from own enumerable keys when
anyis called. ECMAScript own-key order applies: integer-index strings, other strings, then symbols.
Effectful observation
tapvariable
Runs a synchronous or Effectful observation for each matched value and returns the value unchanged.
Error recovery
catchvariable · Re-export
Recovers typed failures and lifts the recovery result into
Some.catchAllvariable
Recovers typed failures and lifts the recovery result into
Some.catchCausevariable
Recovers from the complete Effect Cause and lifts the recovery result into
Some.catchTagvariable
Recovers selected tagged typed failures and leaves unmatched tags in the error channel.
Guard contracts
AsGuardinterface
An object that supplies a Guard through an own callable
asGuardproperty. Use an instance field rather than a prototype method.Guardtype-alias
An effectful partial transformation.
A successful
Somecontains a match, a successfulNonemeans the input did not match, and an Effect failure remains in theEchannel. Required services remain inR.GuardInputtype-alias
A Guard or an object that supplies one. Guard combinators accept either form.
Input selection
filtervariable
Keeps matched values that satisfy a predicate or refinement.
filterMapvariable
Refines and maps a matched value with an Option-returning function.
liftPredicatefunction
Builds a Guard from a predicate or refinement. The predicate is evaluated only when the returned Effect runs. A thrown exception becomes an Effect defect; use an effectful Guard when failure belongs in the typed error channel.
Library adapters
getGuardvariable · Re-export
Returns a callable Guard unchanged or obtains one from an own callable
asGuardproperty. Invalid adapter objects throwTypeErrorimmediately.
Record construction
addTagvariable
Adds a readonly
_tagto every matched object output. The output must not already have an_tagproperty.bindvariable
Runs
fon a matched object and adds its matched value under a new key. The key must not already exist. Enumerable getters and proxy traps may execute during the object spread.bindTovariable
Wraps any matched output in a new object under
key. This is the explicit transition from an arbitrary output to the record-building workflow.letvariable · Re-export
Adds a fixed property to every matched record output.
Schema decoding and encoding
decodevariable
Decodes each matched encoded value through an Effect Schema.
encodevariable
Encodes each matched schema Type to its Encoded representation.
fromSchemaDecodefunction
Creates a Guard that decodes a schema’s Encoded input to its Type.
fromSchemaEncodefunction
Creates a Guard that encodes a schema’s Type to its Encoded representation.
Sequential composition
pipevariable
Runs
outputonly wheninputmatches.Noneshort-circuits successfully, while failures and service requirements are preserved from both Guards.
Services
providevariable
Provides a Context or Layer to a Guard’s Effect.
provideServicevariable
Provides one concrete service to a Guard.
provideServiceEffectvariable
Provides a service produced by an Effect to a Guard.
Type utilities
AnyInputtype-alias
Computes the intersection of inputs accepted by an
anyGuard record.AnyOutputtype-alias
Builds the tagged output union produced by
any.Guard.Errortype-alias
Extracts the typed error channel from a Guard or Guard adapter.
Guard.Inputtype-alias
Extracts the accepted input type from a Guard or Guard adapter.
Guard.Outputtype-alias
Extracts the matched output type from a Guard or Guard adapter.
Guard.Servicestype-alias
Extracts the Effect service requirements from a Guard or Guard adapter.