import type { TypeLambda } from "@effect/data/HKT"; /** * @category models * @since 1.0.0 */ export interface Predicate { (a: A): boolean; } /** * @category type lambdas * @since 1.0.0 */ export interface PredicateTypeLambda extends TypeLambda { readonly type: Predicate; } /** * @category models * @since 1.0.0 */ export interface Refinement { (a: A): a is B; } /** * Given a `Predicate` returns a `Predicate` * * @param self - the `Predicate` to be transformed to `Predicate`. * @param f - a function to transform `B` to `A`. * * @example * import * as P from "@effect/data/Predicate" * import * as N from "@effect/data/Number" * * const minLength3 = P.mapInput(N.greaterThan(2), (s: string) => s.length) * * assert.deepStrictEqual(minLength3("a"), false) * assert.deepStrictEqual(minLength3("aa"), false) * assert.deepStrictEqual(minLength3("aaa"), true) * assert.deepStrictEqual(minLength3("aaaa"), true) * * @category combinators * @since 1.0.0 */ export declare const mapInput: { (f: (b: B) => A): (self: Predicate) => Predicate; (self: Predicate, f: (b: B) => A): Predicate; }; /** * Tests if a value is a `string`. * * @param input - The value to test. * * @example * import { isString } from "@effect/data/Predicate" * * assert.deepStrictEqual(isString("a"), true) * * assert.deepStrictEqual(isString(1), false) * * @category guards * @since 1.0.0 */ export declare const isString: (input: unknown) => input is string; /** * Tests if a value is a `number`. * * @param input - The value to test. * * @example * import { isNumber } from "@effect/data/Predicate" * * assert.deepStrictEqual(isNumber(2), true) * * assert.deepStrictEqual(isNumber("2"), false) * * @category guards * @since 1.0.0 */ export declare const isNumber: (input: unknown) => input is number; /** * Tests if a value is a `boolean`. * * @param input - The value to test. * * @example * import { isBoolean } from "@effect/data/Predicate" * * assert.deepStrictEqual(isBoolean(true), true) * * assert.deepStrictEqual(isBoolean("true"), false) * * @category guards * @since 1.0.0 */ export declare const isBoolean: (input: unknown) => input is boolean; /** * Tests if a value is a `bigint`. * * @param input - The value to test. * * @example * import { isBigint } from "@effect/data/Predicate" * * assert.deepStrictEqual(isBigint(1n), true) * * assert.deepStrictEqual(isBigint(1), false) * * @category guards * @since 1.0.0 */ export declare const isBigint: (input: unknown) => input is bigint; /** * Tests if a value is a `symbol`. * * @param input - The value to test. * * @example * import { isSymbol } from "@effect/data/Predicate" * * assert.deepStrictEqual(isSymbol(Symbol.for("a")), true) * * assert.deepStrictEqual(isSymbol("a"), false) * * @category guards * @since 1.0.0 */ export declare const isSymbol: (input: unknown) => input is symbol; /** * Tests if a value is a `function`. * * @param input - The value to test. * * @example * import { isFunction } from "@effect/data/Predicate" * * assert.deepStrictEqual(isFunction(isFunction), true) * * assert.deepStrictEqual(isFunction("function"), false) * * @category guards * @since 1.0.0 */ export declare const isFunction: (input: unknown) => input is Function; /** * Tests if a value is `undefined`. * * @param input - The value to test. * * @example * import { isUndefined } from "@effect/data/Predicate" * * assert.deepStrictEqual(isUndefined(undefined), true) * * assert.deepStrictEqual(isUndefined(null), false) * assert.deepStrictEqual(isUndefined("undefined"), false) * * @category guards * @since 1.0.0 */ export declare const isUndefined: (input: unknown) => input is undefined; /** * Tests if a value is not `undefined`. * * @param input - The value to test. * * @example * import { isNotUndefined } from "@effect/data/Predicate" * * assert.deepStrictEqual(isNotUndefined(null), true) * assert.deepStrictEqual(isNotUndefined("undefined"), true) * * assert.deepStrictEqual(isNotUndefined(undefined), false) * * @category guards * @since 1.0.0 */ export declare const isNotUndefined: (input: A) => input is Exclude; /** * Tests if a value is `undefined`. * * @param input - The value to test. * * @example * import { isNull } from "@effect/data/Predicate" * * assert.deepStrictEqual(isNull(null), true) * * assert.deepStrictEqual(isNull(undefined), false) * assert.deepStrictEqual(isNull("null"), false) * * @category guards * @since 1.0.0 */ export declare const isNull: (input: unknown) => input is null; /** * Tests if a value is not `undefined`. * * @param input - The value to test. * * @example * import { isNotNull } from "@effect/data/Predicate" * * assert.deepStrictEqual(isNotNull(undefined), true) * assert.deepStrictEqual(isNotNull("null"), true) * * assert.deepStrictEqual(isNotNull(null), false) * * @category guards * @since 1.0.0 */ export declare const isNotNull: (input: A) => input is Exclude; /** * A guard that always fails. * * @param _ - The value to test. * * @example * import { isNever } from "@effect/data/Predicate" * * assert.deepStrictEqual(isNever(null), false) * assert.deepStrictEqual(isNever(undefined), false) * assert.deepStrictEqual(isNever({}), false) * assert.deepStrictEqual(isNever([]), false) * * @category guards * @since 1.0.0 */ export declare const isNever: (input: unknown) => input is never; /** * A guard that always succeeds. * * @param _ - The value to test. * * @example * import { isUnknown } from "@effect/data/Predicate" * * assert.deepStrictEqual(isUnknown(null), true) * assert.deepStrictEqual(isUnknown(undefined), true) * * assert.deepStrictEqual(isUnknown({}), true) * assert.deepStrictEqual(isUnknown([]), true) * * @category guards * @since 1.0.0 */ export declare const isUnknown: (input: unknown) => input is unknown; /** * Tests if a value is an `object`. * * @param input - The value to test. * * @example * import { isObject } from "@effect/data/Predicate" * * assert.deepStrictEqual(isObject({}), true) * assert.deepStrictEqual(isObject([]), true) * * assert.deepStrictEqual(isObject(null), false) * assert.deepStrictEqual(isObject(undefined), false) * * @category guards * @since 1.0.0 */ export declare const isObject: (input: unknown) => input is object; /** * Tests if a value is an `object` with a property `_tag` that matches the given tag. * * @param input - The value to test. * @param tag - The tag to test for. * * @example * import { isTagged } from "@effect/data/Predicate" * * assert.deepStrictEqual(isTagged(1, "a"), false) * assert.deepStrictEqual(isTagged(null, "a"), false) * assert.deepStrictEqual(isTagged({}, "a"), false) * assert.deepStrictEqual(isTagged({ a: "a" }, "a"), false) * assert.deepStrictEqual(isTagged({ _tag: "a" }, "a"), true) * assert.deepStrictEqual(isTagged("a")({ _tag: "a" }), true) * * @category guards * @since 1.0.0 */ export declare const isTagged: { (tag: K): (self: unknown) => self is { _tag: K; }; (self: unknown, tag: K): self is { _tag: K; }; }; /** * A guard that succeeds when the input is `null` or `undefined`. * * @param input - The value to test. * * @example * import { isNullable } from "@effect/data/Predicate" * * assert.deepStrictEqual(isNullable(null), true) * assert.deepStrictEqual(isNullable(undefined), true) * * assert.deepStrictEqual(isNullable({}), false) * assert.deepStrictEqual(isNullable([]), false) * * @category guards * @since 1.0.0 */ export declare const isNullable: (input: A) => input is Extract; /** * A guard that succeeds when the input is not `null` or `undefined`. * * @param input - The value to test. * * @example * import { isNotNullable } from "@effect/data/Predicate" * * assert.deepStrictEqual(isNotNullable({}), true) * assert.deepStrictEqual(isNotNullable([]), true) * * assert.deepStrictEqual(isNotNullable(null), false) * assert.deepStrictEqual(isNotNullable(undefined), false) * * @category guards * @since 1.0.0 */ export declare const isNotNullable: (input: A) => input is NonNullable; /** * A guard that succeeds when the input is an `Error`. * * @param input - The value to test. * * @example * import { isError } from "@effect/data/Predicate" * * assert.deepStrictEqual(isError(new Error()), true) * * assert.deepStrictEqual(isError(null), false) * assert.deepStrictEqual(isError({}), false) * * @category guards * @since 1.0.0 */ export declare const isError: (input: unknown) => input is Error; /** * A guard that succeeds when the input is a `Uint8Array`. * * @param input - The value to test. * * @example * import { isUint8Array } from "@effect/data/Predicate" * * assert.deepStrictEqual(isUint8Array(new Uint8Array()), true) * * assert.deepStrictEqual(isUint8Array(null), false) * assert.deepStrictEqual(isUint8Array({}), false) * * @category guards * @since 1.0.0 */ export declare const isUint8Array: (input: unknown) => input is Uint8Array; /** * A guard that succeeds when the input is a `Date`. * * @param input - The value to test. * * @example * import { isDate } from "@effect/data/Predicate" * * assert.deepStrictEqual(isDate(new Date()), true) * * assert.deepStrictEqual(isDate(null), false) * assert.deepStrictEqual(isDate({}), false) * * @category guards * @since 1.0.0 */ export declare const isDate: (input: unknown) => input is Date; /** * A guard that succeeds when the input is an `Iterable`. * * @param input - The value to test. * * @example * import { isIterable } from "@effect/data/Predicate" * * assert.deepStrictEqual(isIterable([]), true) * assert.deepStrictEqual(isIterable(new Set()), true) * * assert.deepStrictEqual(isIterable(null), false) * assert.deepStrictEqual(isIterable({}), false) * * @category guards * @since 1.0.0 */ export declare const isIterable: (input: unknown) => input is Iterable; /** * A guard that succeeds when the input is a record. * * @param input - The value to test. * * @example * import { isRecord } from "@effect/data/Predicate" * * assert.deepStrictEqual(isRecord({}), true) * assert.deepStrictEqual(isRecord({ a: 1 }), true) * * assert.deepStrictEqual(isRecord([]), false) * assert.deepStrictEqual(isRecord([1, 2, 3]), false) * assert.deepStrictEqual(isRecord(null), false) * assert.deepStrictEqual(isRecord(undefined), false) * * @category guards * @since 1.0.0 */ export declare const isRecord: (input: unknown) => input is { [x: string]: unknown; [x: symbol]: unknown; }; /** * A guard that succeeds when the input is a readonly record. * * @param input - The value to test. * * @example * import { isReadonlyRecord } from "@effect/data/Predicate" * * assert.deepStrictEqual(isReadonlyRecord({}), true) * assert.deepStrictEqual(isReadonlyRecord({ a: 1 }), true) * * assert.deepStrictEqual(isReadonlyRecord([]), false) * assert.deepStrictEqual(isReadonlyRecord([1, 2, 3]), false) * assert.deepStrictEqual(isReadonlyRecord(null), false) * assert.deepStrictEqual(isReadonlyRecord(undefined), false) * * @category guards * @since 1.0.0 */ export declare const isReadonlyRecord: (input: unknown) => input is { readonly [x: string | symbol]: unknown; }; /** * @since 1.0.0 */ export declare const compose: { (bc: Refinement): (ab: Refinement) => Refinement; (ab: Refinement, bc: Refinement): Refinement; }; /** * @category combining * @since 1.0.0 */ export declare const product: (self: Predicate, that: Predicate) => Predicate; /** * @category combining * @since 1.0.0 */ export declare const all: (collection: Iterable>) => Predicate; /** * @category combining * @since 1.0.0 */ export declare const productMany: (self: Predicate, collection: Iterable>) => Predicate; /** * Similar to `Promise.all` but operates on `Predicate`s. * * ``` * [Predicate, Predicate, ...] -> Predicate<[A, B, ...]> * ``` * * @since 1.0.0 */ export declare const tuple: []>(...elements: T) => Predicate] ? A : never; }>>; /** * @since 1.0.0 */ export declare const struct: >>(fields: R) => Predicate<{ readonly [K in keyof R]: [R[K]] extends [Predicate] ? A : never; }>; /** * Negates the result of a given predicate. * * @param self - A predicate. * * @example * import * as P from "@effect/data/Predicate" * import * as N from "@effect/data/Number" * * const isPositive = P.not(N.lessThan(0)) * * assert.deepStrictEqual(isPositive(-1), false) * assert.deepStrictEqual(isPositive(0), true) * assert.deepStrictEqual(isPositive(1), true) * * @category combinators * @since 1.0.0 */ export declare const not: (self: Predicate) => Predicate; /** * Combines two predicates into a new predicate that returns `true` if at least one of the predicates returns `true`. * * @param self - A predicate. * @param that - A predicate. * * @example * import * as P from "@effect/data/Predicate" * import * as N from "@effect/data/Number" * * const nonZero = P.or(N.lessThan(0), N.greaterThan(0)) * * assert.deepStrictEqual(nonZero(-1), true) * assert.deepStrictEqual(nonZero(0), false) * assert.deepStrictEqual(nonZero(1), true) * * @category combinators * @since 1.0.0 */ export declare const or: { (that: Predicate): (self: Predicate) => Predicate; (self: Predicate, that: Predicate): Predicate; }; /** * Combines two predicates into a new predicate that returns `true` if both of the predicates returns `true`. * * @param self - A predicate. * @param that - A predicate. * * @example * import * as P from "@effect/data/Predicate" * * const minLength = (n: number) => (s: string) => s.length >= n * const maxLength = (n: number) => (s: string) => s.length <= n * * const length = (n: number) => P.and(minLength(n), maxLength(n)) * * assert.deepStrictEqual(length(2)("aa"), true) * assert.deepStrictEqual(length(2)("a"), false) * assert.deepStrictEqual(length(2)("aaa"), false) * * @category combinators * @since 1.0.0 */ export declare const and: { (that: Refinement): (self: Refinement) => Refinement; (self: Refinement, that: Refinement): Refinement; (that: Predicate): (self: Predicate) => Predicate; (self: Predicate, that: Predicate): Predicate; }; /** * @category combinators * @since 1.0.0 */ export declare const xor: { (that: Predicate): (self: Predicate) => Predicate; (self: Predicate, that: Predicate): Predicate; }; /** * @category combinators * @since 1.0.0 */ export declare const eqv: { (that: Predicate): (self: Predicate) => Predicate; (self: Predicate, that: Predicate): Predicate; }; /** * @category combinators * @since 1.0.0 */ export declare const implies: { (that: Predicate): (self: Predicate) => Predicate; (self: Predicate, that: Predicate): Predicate; }; /** * @category combinators * @since 1.0.0 */ export declare const nor: { (that: Predicate): (self: Predicate) => Predicate; (self: Predicate, that: Predicate): Predicate; }; /** * @category combinators * @since 1.0.0 */ export declare const nand: { (that: Predicate): (self: Predicate) => Predicate; (self: Predicate, that: Predicate): Predicate; }; /** * @category elements * @since 1.0.0 */ export declare const every: (collection: Iterable>) => Predicate; /** * @category elements * @since 1.0.0 */ export declare const some: (collection: Iterable>) => Predicate; //# sourceMappingURL=Predicate.d.ts.map