Ohm-Management - Projektarbeit B-ME
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

matches.js 1.1KB

123456789101112131415161718192021222324252627282930313233343536373839
  1. var baseClone = require('./_baseClone'),
  2. baseMatches = require('./_baseMatches');
  3. /** Used to compose bitmasks for cloning. */
  4. var CLONE_DEEP_FLAG = 1;
  5. /**
  6. * Creates a function that performs a partial deep comparison between a given
  7. * object and `source`, returning `true` if the given object has equivalent
  8. * property values, else `false`.
  9. *
  10. * **Note:** The created function is equivalent to `_.isMatch` with `source`
  11. * partially applied.
  12. *
  13. * Partial comparisons will match empty array and empty object `source`
  14. * values against any array or object value, respectively. See `_.isEqual`
  15. * for a list of supported value comparisons.
  16. *
  17. * @static
  18. * @memberOf _
  19. * @since 3.0.0
  20. * @category Util
  21. * @param {Object} source The object of property values to match.
  22. * @returns {Function} Returns the new spec function.
  23. * @example
  24. *
  25. * var objects = [
  26. * { 'a': 1, 'b': 2, 'c': 3 },
  27. * { 'a': 4, 'b': 5, 'c': 6 }
  28. * ];
  29. *
  30. * _.filter(objects, _.matches({ 'a': 4, 'c': 6 }));
  31. * // => [{ 'a': 4, 'b': 5, 'c': 6 }]
  32. */
  33. function matches(source) {
  34. return baseMatches(baseClone(source, CLONE_DEEP_FLAG));
  35. }
  36. module.exports = matches;