main
Last change
on this file was d565449, checked in by stefan toskovski <stefantoska84@…>, 4 weeks ago |
Update repo after prototype presentation
|
-
Property mode
set to
100644
|
File size:
716 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 | export default baseConformsTo;
|
---|
Note:
See
TracBrowser
for help on using the repository browser.