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
trusty-cms-6.3.1 node_modules/lodash/partition.js
immosquare-cleaner-0.1.51 node_modules/lodash/partition.js
boring_generators-0.15.0 tmp/templates/app_template/node_modules/lodash/partition.js
clapton-0.0.26 lib/clapton/javascripts/node_modules/lodash/partition.js
clapton-0.0.25 lib/clapton/javascripts/node_modules/lodash/partition.js
immosquare-cleaner-0.1.50 node_modules/lodash/partition.js
clapton-0.0.24 lib/clapton/javascripts/node_modules/lodash/partition.js
clapton-0.0.23 lib/clapton/javascripts/node_modules/lodash/partition.js
clapton-0.0.22 lib/clapton/javascripts/node_modules/lodash/partition.js
clapton-0.0.21 lib/clapton/javascripts/node_modules/lodash/partition.js
clapton-0.0.20 lib/clapton/javascripts/node_modules/lodash/partition.js
clapton-0.0.19 lib/clapton/javascripts/node_modules/lodash/partition.js
clapton-0.0.18 lib/clapton/javascripts/node_modules/lodash/partition.js
clapton-0.0.17 lib/clapton/javascripts/node_modules/lodash/partition.js
clapton-0.0.16 lib/clapton/javascripts/node_modules/lodash/partition.js
clapton-0.0.15 lib/clapton/javascripts/node_modules/lodash/partition.js
immosquare-cleaner-0.1.49 node_modules/lodash/partition.js
clapton-0.0.14 lib/clapton/javascripts/node_modules/lodash/partition.js
immosquare-cleaner-0.1.48 node_modules/lodash/partition.js
clapton-0.0.13 lib/clapton/javascripts/node_modules/lodash/partition.js