omitBy.js 926 B

1234567891011121314151617181920212223242526272829303132
  1. var baseIteratee = require('./_baseIteratee'),
  2. basePickBy = require('./_basePickBy');
  3. /**
  4. * The opposite of `_.pickBy`; this method creates an object composed of
  5. * the own and inherited enumerable string keyed properties of `object` that
  6. * `predicate` doesn't return truthy for. The predicate is invoked with two
  7. * arguments: (value, key).
  8. *
  9. * @static
  10. * @memberOf _
  11. * @since 4.0.0
  12. * @category Object
  13. * @param {Object} object The source object.
  14. * @param {Array|Function|Object|string} [predicate=_.identity]
  15. * The function invoked per property.
  16. * @returns {Object} Returns the new object.
  17. * @example
  18. *
  19. * var object = { 'a': 1, 'b': '2', 'c': 3 };
  20. *
  21. * _.omitBy(object, _.isNumber);
  22. * // => { 'b': '2' }
  23. */
  24. function omitBy(object, predicate) {
  25. predicate = baseIteratee(predicate);
  26. return basePickBy(object, function(value, key) {
  27. return !predicate(value, key);
  28. });
  29. }
  30. module.exports = omitBy;