UNPKG

806 BJavaScriptView Raw
1import baseClone from './_baseClone';
2import baseConforms from './_baseConforms';
3
4/**
5 * Creates a function that invokes the predicate properties of `source` with
6 * the corresponding property values of a given object, returning `true` if
7 * all predicates return truthy, else `false`.
8 *
9 * @static
10 * @memberOf _
11 * @since 4.0.0
12 * @category Util
13 * @param {Object} source The object of property predicates to conform to.
14 * @returns {Function} Returns the new function.
15 * @example
16 *
17 * var users = [
18 * { 'user': 'barney', 'age': 36 },
19 * { 'user': 'fred', 'age': 40 }
20 * ];
21 *
22 * _.filter(users, _.conforms({ 'age': _.partial(_.gt, _, 38) }));
23 * // => [{ 'user': 'fred', 'age': 40 }]
24 */
25function conforms(source) {
26 return baseConforms(baseClone(source, true));
27}
28
29export default conforms;