Last change
on this file since 8d391a1 was 6a3a178, checked in by Ema <ema_spirova@…>, 3 years ago |
initial commit
|
-
Property mode
set to
100644
|
File size:
718 bytes
|
Line | |
---|
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 |
|
---|
20 | if ((value === undefined && !(key in object)) || !predicate(value)) {
|
---|
21 | return false;
|
---|
22 | }
|
---|
23 | }
|
---|
24 | return true;
|
---|
25 | }
|
---|
26 |
|
---|
27 | module.exports = baseConformsTo;
|
---|
Note:
See
TracBrowser
for help on using the repository browser.