| 1 | import { ListIterateeCustom } from '../_internal/ListIterateeCustom.mjs';
|
|---|
| 2 | import { ObjectIterateeCustom } from '../_internal/ObjectIteratee.mjs';
|
|---|
| 3 |
|
|---|
| 4 | /**
|
|---|
| 5 | * Checks if all elements in a collection pass the predicate check.
|
|---|
| 6 | * The predicate is invoked with three arguments: (value, index|key, collection).
|
|---|
| 7 | *
|
|---|
| 8 | * @template T - The type of elements in the collection
|
|---|
| 9 | * @param {ArrayLike<T> | null | undefined} collection - The collection to iterate over
|
|---|
| 10 | * @param {ListIterateeCustom<T, boolean>} [predicate=identity] - The function invoked per iteration
|
|---|
| 11 | * @returns {boolean} Returns true if all elements pass the predicate check, else false
|
|---|
| 12 | *
|
|---|
| 13 | * @example
|
|---|
| 14 | * // Using a function predicate
|
|---|
| 15 | * every([true, 1, null, 'yes'], Boolean)
|
|---|
| 16 | * // => false
|
|---|
| 17 | *
|
|---|
| 18 | * // Using property shorthand
|
|---|
| 19 | * const users = [{ user: 'barney', age: 36 }, { user: 'fred', age: 40 }]
|
|---|
| 20 | * every(users, 'age')
|
|---|
| 21 | * // => true
|
|---|
| 22 | *
|
|---|
| 23 | * // Using matches shorthand
|
|---|
| 24 | * every(users, { age: 36 })
|
|---|
| 25 | * // => false
|
|---|
| 26 | *
|
|---|
| 27 | * // Using matchesProperty shorthand
|
|---|
| 28 | * every(users, ['age', 36])
|
|---|
| 29 | * // => false
|
|---|
| 30 | */
|
|---|
| 31 | declare function every<T>(collection: ArrayLike<T> | null | undefined, predicate?: ListIterateeCustom<T, boolean>): boolean;
|
|---|
| 32 | /**
|
|---|
| 33 | * Checks if all elements in an object pass the predicate check.
|
|---|
| 34 | * The predicate is invoked with three arguments: (value, key, object).
|
|---|
| 35 | *
|
|---|
| 36 | * @template T - The type of the object
|
|---|
| 37 | * @param {T | null | undefined} collection - The object to iterate over
|
|---|
| 38 | * @param {ObjectIterateeCustom<T, boolean>} [predicate=identity] - The function invoked per iteration
|
|---|
| 39 | * @returns {boolean} Returns true if all elements pass the predicate check, else false
|
|---|
| 40 | *
|
|---|
| 41 | * @example
|
|---|
| 42 | * // Using a function predicate
|
|---|
| 43 | * every({ a: true, b: 1, c: null }, Boolean)
|
|---|
| 44 | * // => false
|
|---|
| 45 | *
|
|---|
| 46 | * // Using property shorthand
|
|---|
| 47 | * const users = {
|
|---|
| 48 | * barney: { active: true, age: 36 },
|
|---|
| 49 | * fred: { active: true, age: 40 }
|
|---|
| 50 | * }
|
|---|
| 51 | * every(users, 'active')
|
|---|
| 52 | * // => true
|
|---|
| 53 | *
|
|---|
| 54 | * // Using matches shorthand
|
|---|
| 55 | * every(users, { active: true })
|
|---|
| 56 | * // => true
|
|---|
| 57 | *
|
|---|
| 58 | * // Using matchesProperty shorthand
|
|---|
| 59 | * every(users, ['age', 36])
|
|---|
| 60 | * // => false
|
|---|
| 61 | */
|
|---|
| 62 | declare function every<T extends object>(collection: T | null | undefined, predicate?: ObjectIterateeCustom<T, boolean>): boolean;
|
|---|
| 63 |
|
|---|
| 64 | export { every };
|
|---|