basant307/AI_Governance_Project
045
1import createAggregator from './_createAggregator.js';2 3/**4 * Creates an array of elements split into two groups, the first of which5 * contains elements `predicate` returns truthy for, the second of which6 * contains elements `predicate` returns falsey for. The predicate is7 * invoked with one argument: (value).8 *9 * @static10 * @memberOf _11 * @since 3.0.012 * @category Collection13 * @param {Array|Object} collection The collection to iterate over.14 * @param {Function} [predicate=_.identity] The function invoked per iteration.15 * @returns {Array} Returns the array of grouped elements.16 * @example17 *18 * var users = [19 * { 'user': 'barney', 'age': 36, 'active': false },20 * { 'user': 'fred', 'age': 40, 'active': true },21 * { 'user': 'pebbles', 'age': 1, 'active': false }22 * ];23 *24 * _.partition(users, function(o) { return o.active; });25 * // => objects for [['fred'], ['barney', 'pebbles']]26 *27 * // The `_.matches` iteratee shorthand.28 * _.partition(users, { 'age': 1, 'active': false });29 * // => objects for [['pebbles'], ['barney', 'fred']]30 *31 * // The `_.matchesProperty` iteratee shorthand.32 * _.partition(users, ['active', false]);33 * // => objects for [['barney', 'pebbles'], ['fred']]34 *35 * // The `_.property` iteratee shorthand.36 * _.partition(users, 'active');37 * // => objects for [['fred'], ['barney', 'pebbles']]38 */39var partition = createAggregator(function(result, value, key) {40 result[key ? 0 : 1].push(value);41}, function() { return [[], []]; });42 43export default partition;44 