1 var baseClone = require('./_baseClone'),
2 baseIteratee = require('./_baseIteratee');
5 * Creates a function that invokes `func` with the arguments of the created
6 * function. If `func` is a property name the created callback returns the
7 * property value for a given element. If `func` is an object the created
8 * callback returns `true` for elements that contain the equivalent object properties, otherwise it returns `false`.
13 * @param {*} [func=_.identity] The value to convert to a callback.
14 * @returns {Function} Returns the callback.
18 * { 'user': 'barney', 'age': 36 },
19 * { 'user': 'fred', 'age': 40 }
22 * // Create custom iteratee shorthands.
23 * _.iteratee = _.wrap(_.iteratee, function(callback, func) {
24 * var p = /^(\S+)\s*([<>])\s*(\S+)$/.exec(func);
25 * return !p ? callback(func) : function(object) {
26 * return (p[2] == '>' ? object[p[1]] > p[3] : object[p[1]] < p[3]);
30 * _.filter(users, 'age > 36');
31 * // => [{ 'user': 'fred', 'age': 40 }]
33 function iteratee(func) {
34 return baseIteratee(typeof func == 'function' ? func : baseClone(func, true));
37 module.exports = iteratee;