source: imaps-frontend/node_modules/lodash-es/iteratee.js

main
Last change on this file was d565449, checked in by stefan toskovski <stefantoska84@…>, 4 weeks ago

Update repo after prototype presentation

  • Property mode set to 100644
File size: 1.7 KB
Line 
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 created
9 * function. If `func` is a property name, the created function returns the
10 * property value for a given element. If `func` is an array or object, the
11 * created function returns `true` for elements that contain the equivalent
12 * source properties, otherwise it returns `false`.
13 *
14 * @static
15 * @since 4.0.0
16 * @memberOf _
17 * @category Util
18 * @param {*} [func=_.identity] The value to convert to a callback.
19 * @returns {Function} Returns the callback.
20 * @example
21 *
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;
Note: See TracBrowser for help on using the repository browser.