import createAggregator from './.internal/createAggregator.js'; /** * 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). * * @since 3.0.0 * @category Collection * @param {Array|Object} collection The collection to iterate over. * @param {Function} predicate The function invoked per iteration. * @returns {Array} Returns the array of grouped elements. * @example * * const users = [ * { 'user': 'barney', 'age': 36, 'active': false }, * { 'user': 'fred', 'age': 40, 'active': true }, * { 'user': 'pebbles', 'age': 1, 'active': false } * ]; * * partition(users, o => o.active); * // => objects for [['fred'], ['barney', 'pebbles']] */ const partition = createAggregator((result, value, key) => result[key ? 0 : 1].push(value), () => [[], []]); export default partition;