true when the last lineage segment equals the lineage segment key (usually the resource key).
export const const atLeaf: (
key: string
) => Predicate.Predicate<LogEntry>
true when the last lineage segment equals the lineage segment key (usually the resource key).
atLeaf = (key: string
- Hyperlink key (
Tag.key, e.g. wnba/LiveScorePoller).
key: string): import PredicatePredicate.interface Predicate<in A>A function that decides whether a value of type A satisfies a condition.
When to use
Use when you want a reusable boolean check for A, especially when you plan
to combine checks with
and
/
or
or pass a predicate to arrays
and iterables.
Details
A predicate returns true or false and never throws by itself. It does not
narrow types unless you use Refinement.
Example (Defining a predicate)
import { Predicate } from "effect"
const isPositive: Predicate.Predicate<number> = (n) => n > 0
console.log(isPositive(1))
Type-level utilities for working with
Predicate
types.
When to use
Use when you need to extract input types from predicate signatures while
writing generic helpers over predicate types.
Details
These utilities are type-only, create no runtime values, and the namespace is
erased at runtime.
Example (Extracting predicate input)
import { Predicate } from "effect"
type IsString = Predicate.Predicate<string>
type Input = Predicate.Predicate.In<IsString>
Predicate<LogEntry> => (entry: LogEntry(parameter) entry: {
date: string;
level: LogLevel;
message: string;
cause: string;
annotations: Readonly<Record<string, string>>;
spans: ReadonlyArray<string>;
}
entry) => {
const const segments: readonly string[]segments = const lineage: (
entry: LogEntry
) => ReadonlyArray<string>
Decode lineage segment keys from a captured entry's annotations.
Reads annotation key
LogAnnotationKeys.lineage
only (JSON array of Tag.key segments).
lineage(entry: LogEntry(parameter) entry: {
date: string;
level: LogLevel;
message: string;
cause: string;
annotations: Readonly<Record<string, string>>;
spans: ReadonlyArray<string>;
}
entry);
return const segments: readonly string[]segments[const segments: readonly string[]segments.ReadonlyArray<string>.length: numberGets the length of the array. This is a number one higher than the highest element defined in an array.
length - 1] === key: string
- Hyperlink key (
Tag.key, e.g. wnba/LiveScorePoller).
key;
};