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
clapton-0.0.12 lib/clapton/javascripts/node_modules/lodash/partition.js
clapton-0.0.11 lib/clapton/javascripts/node_modules/lodash/partition.js
clapton-0.0.10 lib/clapton/javascripts/node_modules/lodash/partition.js
clapton-0.0.9 lib/clapton/javascripts/node_modules/lodash/partition.js
clapton-0.0.8 lib/clapton/javascripts/node_modules/lodash/partition.js
clapton-0.0.7 lib/clapton/javascripts/node_modules/lodash/partition.js
clapton-0.0.6 lib/clapton/javascripts/node_modules/lodash/partition.js
clapton-0.0.5 lib/clapton/javascripts/node_modules/lodash/partition.js
clapton-0.0.4 lib/clapton/javascripts/node_modules/lodash/partition.js
clapton-0.0.3 lib/clapton/javascripts/node_modules/lodash/partition.js
clapton-0.0.2 lib/clapton/javascripts/node_modules/lodash/partition.js
clapton-0.0.1 lib/clapton/javascripts/node_modules/lodash/partition.js
immosquare-cleaner-0.1.47 node_modules/lodash/partition.js
immosquare-cleaner-0.1.46 node_modules/lodash/partition.js
immosquare-cleaner-0.1.45 node_modules/lodash/partition.js
immosquare-cleaner-0.1.44 node_modules/lodash/partition.js
boring_generators-0.14.0 tmp/templates/app_template/node_modules/lodash/partition.js
immosquare-cleaner-0.1.43 node_modules/lodash/partition.js
immosquare-cleaner-0.1.42 node_modules/lodash/partition.js
immosquare-cleaner-0.1.41 node_modules/lodash/partition.js