blob: 888434d620e20363bb436f013c060b339fc6b583 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
|
var keys = require('./keys');
/**
* The base implementation of `_.conforms` which doesn't clone `source`.
*
* @private
* @param {Object} source The object of property predicates to conform to.
* @returns {Function} Returns the new function.
*/
function baseConforms(source) {
var props = keys(source),
length = props.length;
return function(object) {
if (object == null) {
return !length;
}
var index = length;
while (index--) {
var key = props[index],
predicate = source[key],
value = object[key];
if ((value === undefined && !(key in Object(object))) || !predicate(value)) {
return false;
}
}
return true;
};
}
module.exports = baseConforms;
|