Start sharing components as a team!Share components as a team!Join Bit to build your applications faster.Get Started Free

iteratee

v4.17.11arrow_drop_down
v4.17.11
STATUS
Passing
DOWNLOADS
139
LICENSE
MIT
VISIBILITY
Public
PUBLISHED
7 months ago
SIZE
9 KB
subject
Creates a function that invokes `func` with the arguments of the created function.
1 contributor
Use iteratee in your project ?
Copied
npm i @bit/lodash.lodash.iteratee
Set Bit as a scoped registryLearn more
npm config set '@bit:registry' https://node.bit.dev
Component Example
React
React
Vue
Angular
Add dependency... help_outline
Just
import
any of the 1 million components
and packages in Bit or NPM to the example.
import Button from '@bit/grommet.grommet.button';
import Lodash from 'lodash';
revert changes
reload
toggle layout
maximize
// The `_.matches` iteratee shorthand.
filter(
  users,
  iteratee({
    user: "barney",
    active: true
  })
modifieddraft
chevron_left
chevron_right
iteratee (
func:*?
) : Function

Creates a function that invokes func with the arguments of the created function. If func is a property name, the created function returns the property value for a given element. If func is an array or object, the created function returns true for elements that contain the equivalent source properties, otherwise it returns false.

Example
var users = [
  { 'user': 'barney', 'age': 36, 'active': true },
  { 'user': 'fred',   'age': 40, 'active': false }
];

// The `_.matches` iteratee shorthand.
_.filter(users, _.iteratee({ 'user': 'barney', 'active': true }));
// => [{ 'user': 'barney', 'age': 36, 'active': true }]

// The `_.matchesProperty` iteratee shorthand.
_.filter(users, _.iteratee(['user', 'fred']));
// => [{ 'user': 'fred', 'age': 40 }]

// The `_.property` iteratee shorthand.
_.map(users, _.iteratee('user'));
// => ['barney', 'fred']

// Create custom iteratee shorthands.
_.iteratee = _.wrap(_.iteratee, function(iteratee, func) {
  return !_.isRegExp(func) ? iteratee(func) : function(string) {
    return func.test(string);
  };
});

_.filter(['abc', 'def'], /ef/);
// => ['def']
Argument
func: *?

The value to convert to a callback.

Returns
Function

Returns the callback.