Security update for Core, with self-updated composer
[yaffs-website] / node_modules / grunt-legacy-util / node_modules / lodash / iteratee.js
1 var baseClone = require('./_baseClone'),
2     baseIteratee = require('./_baseIteratee');
3
4 /**
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`.
9  *
10  * @static
11  * @memberOf _
12  * @category Util
13  * @param {*} [func=_.identity] The value to convert to a callback.
14  * @returns {Function} Returns the callback.
15  * @example
16  *
17  * var users = [
18  *   { 'user': 'barney', 'age': 36 },
19  *   { 'user': 'fred',   'age': 40 }
20  * ];
21  *
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]);
27  *   };
28  * });
29  *
30  * _.filter(users, 'age > 36');
31  * // => [{ 'user': 'fred', 'age': 40 }]
32  */
33 function iteratee(func) {
34   return baseIteratee(typeof func == 'function' ? func : baseClone(func, true));
35 }
36
37 module.exports = iteratee;