mirror of
https://github.com/whoisclebs/lodash.git
synced 2026-01-31 07:17:50 +00:00
30 lines
825 B
JavaScript
30 lines
825 B
JavaScript
import baseClone from './_baseClone.js';
|
|
import baseConforms from './_baseConforms.js';
|
|
|
|
/**
|
|
* Creates a function that invokes the predicate properties of `source` with
|
|
* the corresponding property values of a given object, returning `true` if
|
|
* all predicates return truthy, else `false`.
|
|
*
|
|
* @static
|
|
* @memberOf _
|
|
* @since 4.0.0
|
|
* @category Util
|
|
* @param {Object} source The object of property predicates to conform to.
|
|
* @returns {Function} Returns the new spec function.
|
|
* @example
|
|
*
|
|
* var users = [
|
|
* { 'user': 'barney', 'age': 36 },
|
|
* { 'user': 'fred', 'age': 40 }
|
|
* ];
|
|
*
|
|
* _.filter(users, _.conforms({ 'age': function(n) { return n > 38; } }));
|
|
* // => [{ 'user': 'fred', 'age': 40 }]
|
|
*/
|
|
function conforms(source) {
|
|
return baseConforms(baseClone(source, true));
|
|
}
|
|
|
|
export default conforms;
|