| 1 | /**
|
|---|
| 2 | * Creates a predicate function that checks if a value satisfies all of the given predicates.
|
|---|
| 3 | *
|
|---|
| 4 | * @template T - The type of the value to be checked.
|
|---|
| 5 | * @template U - The first possible type that the value could match.
|
|---|
| 6 | * @template V - The second possible type that the value could match.
|
|---|
| 7 | *
|
|---|
| 8 | * @param {(value: T) => value is U} predicate1 - A function that checks if the value matches type `U`.
|
|---|
| 9 | * @param {(value: T) => value is V} predicate2 - A function that checks if the value matches type `V`.
|
|---|
| 10 | *
|
|---|
| 11 | * @returns {(value: T) => value is U & V} A function that takes a value and returns `true` if all predicates return truthy.
|
|---|
| 12 | *
|
|---|
| 13 | * @example
|
|---|
| 14 | * const func = overEvery(
|
|---|
| 15 | * (value) => typeof value === 'string',
|
|---|
| 16 | * (value) => value === 'hello'
|
|---|
| 17 | * );
|
|---|
| 18 | *
|
|---|
| 19 | * func("hello"); // true
|
|---|
| 20 | * func("world"); // false
|
|---|
| 21 | * func(42); // false
|
|---|
| 22 | */
|
|---|
| 23 | declare function overEvery<T, U extends T, V extends T>(predicate1: (value: T) => value is U, predicate2: (value: T) => value is V): (value: T) => value is U & V;
|
|---|
| 24 | /**
|
|---|
| 25 | * Creates a function that checks if all of the given predicates return truthy for the provided values.
|
|---|
| 26 | *
|
|---|
| 27 | * @template T - The type of the values to be checked.
|
|---|
| 28 | *
|
|---|
| 29 | * @param {...Array<((...values: T[]) => boolean) | ReadonlyArray<(...values: T[]) => boolean>>} predicates -
|
|---|
| 30 | * A list of predicates or arrays of predicates. Each predicate is a function that takes one or more values of
|
|---|
| 31 | * type `T` and returns a boolean indicating whether the condition is satisfied for those values.
|
|---|
| 32 | *
|
|---|
| 33 | * @returns {(...values: T[]) => boolean} A function that takes a list of values and returns `true` if all of the
|
|---|
| 34 | * predicates return truthy for the provided values, and `false` otherwise.
|
|---|
| 35 | *
|
|---|
| 36 | * @example
|
|---|
| 37 | * const func = overEvery(
|
|---|
| 38 | * (value) => typeof value === 'string',
|
|---|
| 39 | * (value) => value.length > 3
|
|---|
| 40 | * );
|
|---|
| 41 | *
|
|---|
| 42 | * func("hello"); // true
|
|---|
| 43 | * func("hi"); // false
|
|---|
| 44 | * func(42); // false
|
|---|
| 45 | *
|
|---|
| 46 | * @example
|
|---|
| 47 | * const func = overEvery([
|
|---|
| 48 | * (value) => value.a > 0,
|
|---|
| 49 | * (value) => value.b > 0
|
|---|
| 50 | * ]);
|
|---|
| 51 | *
|
|---|
| 52 | * func({ a: 1, b: 2 }); // true
|
|---|
| 53 | * func({ a: 0, b: 2 }); // false
|
|---|
| 54 | *
|
|---|
| 55 | * @example
|
|---|
| 56 | * const func = overEvery(
|
|---|
| 57 | * (a, b) => typeof a === 'string' && typeof b === 'string',
|
|---|
| 58 | * (a, b) => a.length > 3 && b.length > 3
|
|---|
| 59 | * );
|
|---|
| 60 | *
|
|---|
| 61 | * func("hello", "world"); // true
|
|---|
| 62 | * func("hi", "world"); // false
|
|---|
| 63 | * func(1, 10); // false
|
|---|
| 64 | */
|
|---|
| 65 | declare function overEvery<T>(...predicates: Array<((...args: T[]) => boolean) | ReadonlyArray<(...args: T[]) => boolean>>): (...args: T[]) => boolean;
|
|---|
| 66 |
|
|---|
| 67 | export { overEvery };
|
|---|