mirror of
https://github.com/whoisclebs/lodash.git
synced 2026-02-02 16:17:50 +00:00
Move internal modules to “internal” folder.
This commit is contained in:
27
.internal/baseConformsTo.js
Normal file
27
.internal/baseConformsTo.js
Normal file
@@ -0,0 +1,27 @@
|
||||
/**
|
||||
* 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;
|
||||
Reference in New Issue
Block a user