Options
All
  • Public
  • Public/Protected
  • All
Menu

Module find

Index

References

Functions Collection

References

Renames and re-exports find

Collection Functions

  • find<T>(collection: ArrayLike<T>, predicate?: string, fromIndex?: number): T | undefined
  • find<T>(collection: ArrayLike<T>, predicate?: ((item: T) => boolean), fromIndex?: number): T | undefined
  • find<T>(collection: ArrayLike<T>, predicate?: Partial<T>, fromIndex?: number): T | undefined
  • find<T>(collection: ArrayLike<T>, predicate?: any, fromIndex?: number): T | undefined
  • Iterates over elements of collection, returning the first element predicate returns truthy for. The predicate is invoked with three arguments: (value, index|key, collection).

    since

    5.2.0

    example
    var users = [
    { 'user': 'barney', 'age': 36, 'active': true },
    { 'user': 'fred', 'age': 40, 'active': false },
    { 'user': 'pebbles', 'age': 1, 'active': true }
    ];

    find(users, function(o) { return o.age < 40; });
    // => object for 'barney'

    // The `matches` iteratee shorthand.
    find(users, { 'age': 1, 'active': true });
    // => object for 'pebbles'

    // The `matchesProperty` iteratee shorthand.
    find(users, ['active', false]);
    // => object for 'fred'

    // The `property` iteratee shorthand.
    find(users, 'active');
    // => object for 'barney'

    Type Parameters

    • T

    Parameters

    • collection: ArrayLike<T>

      The collection to inspect.

    • Optional predicate: string

      function invoked per iteration.

    • Optional fromIndex: number

      The index to search from.

    Returns T | undefined

    Returns the matched element, else undefined.

  • Type Parameters

    • T

    Parameters

    • collection: ArrayLike<T>
    • Optional predicate: ((item: T) => boolean)
        • (item: T): boolean
        • Parameters

          • item: T

          Returns boolean

    • Optional fromIndex: number

    Returns T | undefined

  • Type Parameters

    • T

    Parameters

    • collection: ArrayLike<T>
    • Optional predicate: Partial<T>
    • Optional fromIndex: number

    Returns T | undefined

  • Type Parameters

    • T

    Parameters

    • collection: ArrayLike<T>
    • Optional predicate: any
    • Optional fromIndex: number

    Returns T | undefined