omitBy.js 854 B

123456789101112131415161718192021222324252627282930
  1. var baseIteratee = require('./_baseIteratee'),
  2. negate = require('./negate'),
  3. pickBy = require('./pickBy');
  4. /**
  5. * The opposite of `_.pickBy`; this method creates an object composed of
  6. * the own and inherited enumerable string keyed properties of `object` that
  7. * `predicate` doesn't return truthy for. The predicate is invoked with two
  8. * arguments: (value, key).
  9. *
  10. * @static
  11. * @memberOf _
  12. * @since 4.0.0
  13. * @category Object
  14. * @param {Object} object The source object.
  15. * @param {Function} [predicate=_.identity] 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. return pickBy(object, negate(baseIteratee(predicate)));
  26. }
  27. module.exports = omitBy;