Function invokeMap

  • Invokes the method at path of each element in collection, returning an array of the results of each invoked method. Any additional arguments are provided to each invoked method. If path is a function, it's invoked for, and this bound to, each element in collection.

    Parameters

    • collection: Collection

      The collection to iterate over.

    • path: ArrayPath

      The path of the method to invoke or the function invoked per iteration.

    • ...args: any[]

      The arguments to invoke each method with.

    Returns any[]

    Returns the array of results.

    5.12.0

    invokeMap([[5, 1, 7], [3, 2, 1]], 'sort')
    // => [[1, 5, 7], [1, 2, 3]]

    invokeMap([123, 456], String.prototype.split, [''])
    // => [['1', '2', '3'], ['4', '5', '6']]
  • Invokes the method at path of each element in collection, returning an array of the results of each invoked method. Any additional arguments are provided to each invoked method. If path is a function, it's invoked for, and this bound to, each element in collection.

    Type Parameters

    • T
    • F extends (...args: any[]) => any

    Parameters

    • collection: Collection<T>

      The collection to iterate over.

    • path: F

      The path of the method to invoke or the function invoked per iteration.

    • ...args: Parameters<F>

      The arguments to invoke each method with.

    Returns ReturnType<F>[]

    Returns the array of results.

    5.12.0

    invokeMap([[5, 1, 7], [3, 2, 1]], 'sort')
    // => [[1, 5, 7], [1, 2, 3]]

    invokeMap([123, 456], String.prototype.split, [''])
    // => [['1', '2', '3'], ['4', '5', '6']]
  • Invokes the method at path of each element in collection, returning an array of the results of each invoked method. Any additional arguments are provided to each invoked method. If path is a function, it's invoked for, and this bound to, each element in collection.

    Parameters

    • collection: any

      The collection to iterate over.

    • Optionalpath: any

      The path of the method to invoke or the function invoked per iteration.

    • ...args: any[]

      The arguments to invoke each method with.

    Returns any

    Returns the array of results.

    5.12.0

    invokeMap([[5, 1, 7], [3, 2, 1]], 'sort')
    // => [[1, 5, 7], [1, 2, 3]]

    invokeMap([123, 456], String.prototype.split, [''])
    // => [['1', '2', '3'], ['4', '5', '6']]