Sha256: 25e2fa2769d0c1f46f462aa42cd4e19684cfea908dfc5e14071cae6871d2e879

Contents?: true

Size: 1.48 KB

Versions: 265

Compression:

Stored size: 1.48 KB

Contents

var createAggregator = require('./_createAggregator');

/**
 * Creates an array of elements split into two groups, the first of which
 * contains elements `predicate` returns truthy for, the second of which
 * contains elements `predicate` returns falsey for. The predicate is
 * invoked with one argument: (value).
 *
 * @static
 * @memberOf _
 * @since 3.0.0
 * @category Collection
 * @param {Array|Object} collection The collection to iterate over.
 * @param {Function} [predicate=_.identity] The function invoked per iteration.
 * @returns {Array} Returns the array of grouped elements.
 * @example
 *
 * var users = [
 *   { 'user': 'barney',  'age': 36, 'active': false },
 *   { 'user': 'fred',    'age': 40, 'active': true },
 *   { 'user': 'pebbles', 'age': 1,  'active': false }
 * ];
 *
 * _.partition(users, function(o) { return o.active; });
 * // => objects for [['fred'], ['barney', 'pebbles']]
 *
 * // The `_.matches` iteratee shorthand.
 * _.partition(users, { 'age': 1, 'active': false });
 * // => objects for [['pebbles'], ['barney', 'fred']]
 *
 * // The `_.matchesProperty` iteratee shorthand.
 * _.partition(users, ['active', false]);
 * // => objects for [['barney', 'pebbles'], ['fred']]
 *
 * // The `_.property` iteratee shorthand.
 * _.partition(users, 'active');
 * // => objects for [['fred'], ['barney', 'pebbles']]
 */
var partition = createAggregator(function(result, value, key) {
  result[key ? 0 : 1].push(value);
}, function() { return [[], []]; });

module.exports = partition;

Version data entries

265 entries across 263 versions & 30 rubygems

Version Path
sumomo-0.10.0 data/sumomo/api_modules/node_modules/lodash/partition.js
reed_sdk-1.0.1 node_modules/lodash/partition.js
reed_sdk-1.0.0 node_modules/lodash/partition.js
boring_generators-0.12.0 tmp/templates/app_template/node_modules/lodash/partition.js
sumomo-0.9.0 data/sumomo/api_modules/node_modules/lodash/partition.js
sumomo-0.8.22 data/sumomo/api_modules/node_modules/lodash/partition.js
sumomo-0.8.21 data/sumomo/api_modules/node_modules/lodash/partition.js
sumomo-0.8.20 data/sumomo/api_modules/node_modules/lodash/partition.js
sumomo-0.8.17 data/sumomo/api_modules/node_modules/lodash/partition.js
sumomo-0.8.16 data/sumomo/api_modules/node_modules/lodash/partition.js
disco_app-0.18.0 test/dummy/node_modules/lodash/partition.js
disco_app-0.18.2 test/dummy/node_modules/lodash/partition.js
sumomo-0.8.15 data/sumomo/api_modules/node_modules/lodash/partition.js
trusty-cms-5.0.7 node_modules/lodash/partition.js
appmap-0.72.2 ./node_modules/lodash/partition.js
trusty-cms-5.0.6 node_modules/lodash/partition.js
appmap-0.72.1 ./node_modules/lodash/partition.js
appmap-0.72.0 ./node_modules/lodash/partition.js
trusty-cms-5.0.5 node_modules/lodash/partition.js
trusty-cms-5.0.4 node_modules/lodash/partition.js