(input: unknown): Result.Result<bigint, unknown>A predefined filter that only passes through bigint primitive values.
When to use
Use to keep primitive big integer values from unknown input while staying in
the composable Filter / Result pipeline.
Details
Implemented with fromPredicate(Predicate.isBigInt), so values where
typeof input === "bigint" succeed and all other inputs fail with the
original input.
Gotchas
This filter does not coerce numbers or strings; 1n passes while 1 fails.
export const const bigint: Filter<unknown, bigint>A predefined filter that only passes through bigint primitive values.
When to use
Use to keep primitive big integer values from unknown input while staying in
the composable Filter / Result pipeline.
Details
Implemented with fromPredicate(Predicate.isBigInt), so values where
typeof input === "bigint" succeed and all other inputs fail with the
original input.
Gotchas
This filter does not coerce numbers or strings; 1n passes while 1 fails.
bigint: interface Filter<in Input, out Pass = Input, out Fail = Input>Represents a filter function that can transform inputs to outputs or filter them out.
Details
A filter takes an input value and either returns a boxed pass value or the
special fail type to indicate the value should be filtered out.
Example (Defining a positive number filter)
import { Filter, Result } from "effect"
// A filter that only passes positive numbers
const positiveFilter: Filter.Filter<number> = (n) => n > 0 ? Result.succeed(n) : Result.fail(n)
console.log(positiveFilter(5)) // Result.succeed(5)
console.log(positiveFilter(-3)) // Result.fail(-3)
Filter<unknown, bigint> = const fromPredicate: {
<A, B extends A>(
refinement: Predicate.Refinement<A, B>
): Filter<
A,
B,
EqualsWith<A, B, A, Exclude<A, B>>
>
<A>(
predicate: Predicate.Predicate<A>
): Filter<A>
}
fromPredicate(import PredicatePredicate.function isBigInt(
input: unknown
): input is bigint
Checks whether a value is a bigint.
When to use
Use when you need a Predicate guard to narrow an unknown value to a
bigint.
Details
Uses typeof input === "bigint".
Example (Guarding bigints)
import { Predicate } from "effect"
const data: unknown = 1n
if (Predicate.isBigInt(data)) {
console.log(data + 2n)
}
isBigInt)