array/unionBy.js

  1. import _unionBy from 'lodash/unionBy'
  2. import { convert } from 'util/convert'
  3. /**
  4. * This method is like {@link array.union} except that it accepts <code>iteratee</code> to generate the criterion by which elements are compared.
  5. * @function
  6. * @memberof array
  7. * @param {Object} object The object to modify.
  8. * @param {Array|string} path The path of the property to set.
  9. * @param {...Array} [arrays] The arrays to inspect.
  10. * @param {Function} [iteratee={@link https://lodash.com/docs#identity|lodash.identity}] The iteratee invoked per element.
  11. * @return {Object} Returns the updated object.
  12. * @example unionBy({ nested: { prop: [{ x: 1 }, { x: 2 }] } }, 'nested.prop', [{ x: 2 }, { x: 3 }], 'x') // => { nested: { prop: [{ x: 1 }, { x: 2 }, { x: 3 }] } }
  13. * @see {@link https://lodash.com/docs#unionBy|lodash.unionBy} for more information.
  14. * @since 0.3.0
  15. */
  16. const unionBy = convert(_unionBy)
  17. export { unionBy, unionBy as default }