| 1 | /**
|
|---|
| 2 | * Creates a predicate function that checks if a value satisfies at least one 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 any predicates return truthy.
|
|---|
| 12 | *
|
|---|
| 13 | * @example
|
|---|
| 14 | * const func = overSome(
|
|---|
| 15 | * (value) => typeof value === 'string',
|
|---|
| 16 | * (value) => typeof value === 'number'
|
|---|
| 17 | * );
|
|---|
| 18 | *
|
|---|
| 19 | * func("hello"); // true
|
|---|
| 20 | * func(42); // true
|
|---|
| 21 | * func([]); // false
|
|---|
| 22 | */
|
|---|
| 23 | declare function overSome<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 any 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 any of the
|
|---|
| 34 | * predicates return truthy for the provided values, and `false` otherwise.
|
|---|
| 35 | *
|
|---|
| 36 | * @example
|
|---|
| 37 | * const func = overSome(
|
|---|
| 38 | * (value) => typeof value === 'string',
|
|---|
| 39 | * (value) => typeof value === 'number',
|
|---|
| 40 | * (value) => typeof value === 'symbol'
|
|---|
| 41 | * );
|
|---|
| 42 | *
|
|---|
| 43 | * func("hello"); // true
|
|---|
| 44 | * func(42); // true
|
|---|
| 45 | * func(Symbol()); // true
|
|---|
| 46 | * func([]); // false
|
|---|
| 47 | *
|
|---|
| 48 | * @example
|
|---|
| 49 | * const func = overSome([
|
|---|
| 50 | * (value) => value.a > 0,
|
|---|
| 51 | * (value) => value.b > 0
|
|---|
| 52 | * ]);
|
|---|
| 53 | *
|
|---|
| 54 | * func({ a: 0, b: 2 }); // true
|
|---|
| 55 | * func({ a: 0, b: 0 }); // false
|
|---|
| 56 | *
|
|---|
| 57 | * @example
|
|---|
| 58 | * const func = overSome(
|
|---|
| 59 | * (a, b) => typeof a === 'string' && typeof b === 'string',
|
|---|
| 60 | * (a, b) => a > 0 && b > 0
|
|---|
| 61 | * );
|
|---|
| 62 | *
|
|---|
| 63 | * func("hello", "world"); // true
|
|---|
| 64 | * func(1, 10); // true
|
|---|
| 65 | * func(0, 2); // false
|
|---|
| 66 | */
|
|---|
| 67 | declare function overSome<T>(...predicates: Array<((...values: T[]) => boolean) | ReadonlyArray<(...values: T[]) => boolean>>): (...values: T[]) => boolean;
|
|---|
| 68 |
|
|---|
| 69 | export { overSome };
|
|---|