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.

27 lines
718 B

4 years ago
  1. /**
  2. * The base implementation of `_.conformsTo` which accepts `props` to check.
  3. *
  4. * @private
  5. * @param {Object} object The object to inspect.
  6. * @param {Object} source The object of property predicates to conform to.
  7. * @returns {boolean} Returns `true` if `object` conforms, else `false`.
  8. */
  9. function baseConformsTo(object, source, props) {
  10. var length = props.length;
  11. if (object == null) {
  12. return !length;
  13. }
  14. object = Object(object);
  15. while (length--) {
  16. var key = props[length],
  17. predicate = source[key],
  18. value = object[key];
  19. if ((value === undefined && !(key in object)) || !predicate(value)) {
  20. return false;
  21. }
  22. }
  23. return true;
  24. }
  25. module.exports = baseConformsTo;