Security update for permissions_by_term
[yaffs-website] / node_modules / uncss / node_modules / lodash / iteratee.js
1 var baseIteratee = require('./internal/baseIteratee'),
2     isArray = require('./isArray'),
3     isObjectLike = require('./isObjectLike'),
4     matches = require('./matches');
5
6 /**
7  * Creates a function that invokes `func` with the arguments of the created
8  * function. If `func` is a property name the created callback returns the
9  * property value for a given element. If `func` is an object the created
10  * callback returns `true` for elements that contain the equivalent object properties, otherwise it returns `false`.
11  *
12  * @static
13  * @memberOf _
14  * @category Util
15  * @param {*} [func=_.identity] The value to convert to a callback.
16  * @returns {Function} Returns the callback.
17  * @example
18  *
19  * var users = [
20  *   { 'user': 'barney', 'age': 36 },
21  *   { 'user': 'fred',   'age': 40 }
22  * ];
23  *
24  * // create custom iteratee shorthands
25  * _.iteratee = _.wrap(_.iteratee, function(callback, func) {
26  *   var p = /^(\S+)\s*([<>])\s*(\S+)$/.exec(func);
27  *   return !p ? callback(func) : function(object) {
28  *     return (p[2] == '>' ? object[p[1]] > p[3] : object[p[1]] < p[3]);
29  *   };
30  * });
31  *
32  * _.filter(users, 'age > 36');
33  * // => [{ 'user': 'fred', 'age': 40 }]
34  */
35 function iteratee(func) {
36   return (isObjectLike(func) && !isArray(func))
37     ? matches(func)
38     : baseIteratee(func);
39 }
40
41 module.exports = iteratee;