mirror of
https://github.com/whoisclebs/lodash.git
synced 2026-02-01 15:57:48 +00:00
28 lines
711 B
JavaScript
28 lines
711 B
JavaScript
/**
|
|
* The base implementation of `conformsTo` which accepts `props` to check.
|
|
*
|
|
* @private
|
|
* @param {Object} object The object to inspect.
|
|
* @param {Object} source The object of property predicates to conform to.
|
|
* @returns {boolean} Returns `true` if `object` conforms, else `false`.
|
|
*/
|
|
function baseConformsTo(object, source, props) {
|
|
let length = props.length
|
|
if (object == null) {
|
|
return !length
|
|
}
|
|
object = Object(object)
|
|
while (length--) {
|
|
const key = props[length]
|
|
const predicate = source[key]
|
|
const value = object[key]
|
|
|
|
if ((value === undefined && !(key in object)) || !predicate(value)) {
|
|
return false
|
|
}
|
|
}
|
|
return true
|
|
}
|
|
|
|
export default baseConformsTo
|