Last change
on this file since 6fe77af was 6a3a178, checked in by Ema <ema_spirova@…>, 3 years ago |
initial commit
|
-
Property mode
set to
100644
|
File size:
954 bytes
|
Rev | Line | |
---|
[6a3a178] | 1 | var baseConformsTo = require('./_baseConformsTo'),
|
---|
| 2 | keys = require('./keys');
|
---|
| 3 |
|
---|
| 4 | /**
|
---|
| 5 | * Checks if `object` conforms to `source` by invoking the predicate
|
---|
| 6 | * properties of `source` with the corresponding property values of `object`.
|
---|
| 7 | *
|
---|
| 8 | * **Note:** This method is equivalent to `_.conforms` when `source` is
|
---|
| 9 | * partially applied.
|
---|
| 10 | *
|
---|
| 11 | * @static
|
---|
| 12 | * @memberOf _
|
---|
| 13 | * @since 4.14.0
|
---|
| 14 | * @category Lang
|
---|
| 15 | * @param {Object} object The object to inspect.
|
---|
| 16 | * @param {Object} source The object of property predicates to conform to.
|
---|
| 17 | * @returns {boolean} Returns `true` if `object` conforms, else `false`.
|
---|
| 18 | * @example
|
---|
| 19 | *
|
---|
| 20 | * var object = { 'a': 1, 'b': 2 };
|
---|
| 21 | *
|
---|
| 22 | * _.conformsTo(object, { 'b': function(n) { return n > 1; } });
|
---|
| 23 | * // => true
|
---|
| 24 | *
|
---|
| 25 | * _.conformsTo(object, { 'b': function(n) { return n > 2; } });
|
---|
| 26 | * // => false
|
---|
| 27 | */
|
---|
| 28 | function conformsTo(object, source) {
|
---|
| 29 | return source == null || baseConformsTo(object, source, keys(source));
|
---|
| 30 | }
|
---|
| 31 |
|
---|
| 32 | module.exports = conformsTo;
|
---|
Note:
See
TracBrowser
for help on using the repository browser.