basant307/AI_Governance_Project
048
1import baseClone from './_baseClone.js';2import baseIteratee from './_baseIteratee.js';3 4/** Used to compose bitmasks for cloning. */5var CLONE_DEEP_FLAG = 1;6 7/**8 * Creates a function that invokes `func` with the arguments of the created9 * function. If `func` is a property name, the created function returns the10 * property value for a given element. If `func` is an array or object, the11 * created function returns `true` for elements that contain the equivalent12 * source properties, otherwise it returns `false`.13 *14 * @static15 * @since 4.0.016 * @memberOf _17 * @category Util18 * @param {*} [func=_.identity] The value to convert to a callback.19 * @returns {Function} Returns the callback.20 * @example21 *22 * var users = [23 * { 'user': 'barney', 'age': 36, 'active': true },24 * { 'user': 'fred', 'age': 40, 'active': false }25 * ];26 *27 * // The `_.matches` iteratee shorthand.28 * _.filter(users, _.iteratee({ 'user': 'barney', 'active': true }));29 * // => [{ 'user': 'barney', 'age': 36, 'active': true }]30 *31 * // The `_.matchesProperty` iteratee shorthand.32 * _.filter(users, _.iteratee(['user', 'fred']));33 * // => [{ 'user': 'fred', 'age': 40 }]34 *35 * // The `_.property` iteratee shorthand.36 * _.map(users, _.iteratee('user'));37 * // => ['barney', 'fred']38 *39 * // Create custom iteratee shorthands.40 * _.iteratee = _.wrap(_.iteratee, function(iteratee, func) {41 * return !_.isRegExp(func) ? iteratee(func) : function(string) {42 * return func.test(string);43 * };44 * });45 *46 * _.filter(['abc', 'def'], /ef/);47 * // => ['def']48 */49function iteratee(func) {50 return baseIteratee(typeof func == 'function' ? func : baseClone(func, CLONE_DEEP_FLAG));51}52 53export default iteratee;54 