Sha256: 426c1e48d43c871ccf1eb7553f22b6991aacfe1468d2e9951cc1987a0fa92c03

Contents?: true

Size: 1.41 KB

Versions: 270

Compression:

Stored size: 1.41 KB

Contents

var apply = require('./_apply'),
    baseEach = require('./_baseEach'),
    baseInvoke = require('./_baseInvoke'),
    baseRest = require('./_baseRest'),
    isArrayLike = require('./isArrayLike');

/**
 * 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`.
 *
 * @static
 * @memberOf _
 * @since 4.0.0
 * @category Collection
 * @param {Array|Object} collection The collection to iterate over.
 * @param {Array|Function|string} path The path of the method to invoke or
 *  the function invoked per iteration.
 * @param {...*} [args] The arguments to invoke each method with.
 * @returns {Array} Returns the array of results.
 * @example
 *
 * _.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']]
 */
var invokeMap = baseRest(function(collection, path, args) {
  var index = -1,
      isFunc = typeof path == 'function',
      result = isArrayLike(collection) ? Array(collection.length) : [];

  baseEach(collection, function(value) {
    result[++index] = isFunc ? apply(path, value, args) : baseInvoke(value, path, args);
  });
  return result;
});

module.exports = invokeMap;

Version data entries

270 entries across 269 versions & 28 rubygems

Version Path
immosquare-cleaner-0.1.60 node_modules/lodash/invokeMap.js
immosquare-cleaner-0.1.59 node_modules/lodash/invokeMap.js
immosquare-cleaner-0.1.58 node_modules/lodash/invokeMap.js
immosquare-cleaner-0.1.57 node_modules/lodash/invokeMap.js
immosquare-cleaner-0.1.56 node_modules/lodash/invokeMap.js
immosquare-cleaner-0.1.55 node_modules/lodash/invokeMap.js
immosquare-cleaner-0.1.54 node_modules/lodash/invokeMap.js
immosquare-cleaner-0.1.53 node_modules/lodash/invokeMap.js
immosquare-cleaner-0.1.52 node_modules/lodash/invokeMap.js
trusty-cms-6.3.1 node_modules/lodash/invokeMap.js
immosquare-cleaner-0.1.51 node_modules/lodash/invokeMap.js
boring_generators-0.15.0 tmp/templates/app_template/node_modules/lodash/invokeMap.js
clapton-0.0.26 lib/clapton/javascripts/node_modules/lodash/invokeMap.js
clapton-0.0.25 lib/clapton/javascripts/node_modules/lodash/invokeMap.js
immosquare-cleaner-0.1.50 node_modules/lodash/invokeMap.js
clapton-0.0.24 lib/clapton/javascripts/node_modules/lodash/invokeMap.js
clapton-0.0.23 lib/clapton/javascripts/node_modules/lodash/invokeMap.js
clapton-0.0.22 lib/clapton/javascripts/node_modules/lodash/invokeMap.js
clapton-0.0.21 lib/clapton/javascripts/node_modules/lodash/invokeMap.js
clapton-0.0.20 lib/clapton/javascripts/node_modules/lodash/invokeMap.js