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:
976 bytes
|
Line | |
---|
1 | import baseClone from './_baseClone.js';
|
---|
2 | import baseConforms from './_baseConforms.js';
|
---|
3 |
|
---|
4 | /** Used to compose bitmasks for cloning. */
|
---|
5 | var CLONE_DEEP_FLAG = 1;
|
---|
6 |
|
---|
7 | /**
|
---|
8 | * Creates a function that invokes the predicate properties of `source` with
|
---|
9 | * the corresponding property values of a given object, returning `true` if
|
---|
10 | * all predicates return truthy, else `false`.
|
---|
11 | *
|
---|
12 | * **Note:** The created function is equivalent to `_.conformsTo` with
|
---|
13 | * `source` partially applied.
|
---|
14 | *
|
---|
15 | * @static
|
---|
16 | * @memberOf _
|
---|
17 | * @since 4.0.0
|
---|
18 | * @category Util
|
---|
19 | * @param {Object} source The object of property predicates to conform to.
|
---|
20 | * @returns {Function} Returns the new spec function.
|
---|
21 | * @example
|
---|
22 | *
|
---|
23 | * var objects = [
|
---|
24 | * { 'a': 2, 'b': 1 },
|
---|
25 | * { 'a': 1, 'b': 2 }
|
---|
26 | * ];
|
---|
27 | *
|
---|
28 | * _.filter(objects, _.conforms({ 'b': function(n) { return n > 1; } }));
|
---|
29 | * // => [{ 'a': 1, 'b': 2 }]
|
---|
30 | */
|
---|
31 | function conforms(source) {
|
---|
32 | return baseConforms(baseClone(source, CLONE_DEEP_FLAG));
|
---|
33 | }
|
---|
34 |
|
---|
35 | export default conforms;
|
---|
Note:
See
TracBrowser
for help on using the repository browser.