Codota Logo For Javascript
findIndex
Code IndexAdd Codota to your IDE (free)

How to use
findIndex
function
in
lodash

Best JavaScript code snippets using lodash.findIndex(Showing top 15 results out of 315)

origin: RisingStack/trace-nodejs

function rewind (history, p) {
 if (!p) {
  return history
 }
 var i = findIndex(history, p)
 if (i === -1) {
  return undefined
 }
 return history.slice(i)
}
origin: jquatier/eureka-js-client

modifyInstance(cache, instance) {
  const vipAddresses = this.splitVipAddress(instance.vipAddress);
  const appName = instance.app.toUpperCase();
  vipAddresses.forEach((vipAddress) => {
   const index = findIndex(cache.vip[vipAddress], findInstance(instance));
   if (index > -1) cache.vip[vipAddress].splice(index, 1, instance);
   else this.addInstance(cache, instance);
  });
  const index = findIndex(cache.app[appName], findInstance(instance));
  if (index > -1) cache.app[appName].splice(cache.vip[instance.vipAddress], 1, instance);
  else this.addInstance(cache, instance);
 }
origin: t7/react-starter

// Set default state.
 defaultState () {
  const options = this.props.options

  const checkedIndex = findIndex(options, function (item) {
   return item.checked || item.defaultChecked
  })

  const listName = this.props.listName || utils.unique()

  this.state = {
   checkedIndex: checkedIndex,
   listName: listName
  }
 }
origin: mariobermudezjr/ecommerce-react-graphql-stripe

componentWillReceiveProps(nextProps) {
  if (this.state.environmentIndex === -1 && nextProps.envParams) {
   this.setState({ environmentIndex: findIndex(nextProps.environments, ['name', nextProps.envParams]) });
  }

  if (nextProps.envParams && nextProps.envParams !== this.props.envParams) {
   const environmentIndex = findIndex(nextProps.environments, ['name', nextProps.envParams]);
   this.setState({ environmentIndex });
  }
 }
origin: mariobermudezjr/ecommerce-react-graphql-stripe

export function checkFormValidity(formData, formValidations) {
 const errors = [];

 forEach(formData, (value, key) => {
  const validationValue = formValidations[findIndex(formValidations, ['name', key])];

  if (!isUndefined(validationValue)) {
   const inputErrors = validate(value, validationValue.validations);

   if (!isEmpty(inputErrors)) {
    errors.push({ name: key, errors: inputErrors });
   }

  }
 });

 return errors;
}
origin: mariobermudezjr/ecommerce-react-graphql-stripe

state
     .set('showButtons', showButtons)
     .updateIn(['model', 'attributes'], (list) => list.splice(action.position, 1))
     .updateIn(['model', 'attributes'], (list) => list.splice(findIndex(list.toJS(), ['name', attributeKey]), 1))
origin: sreenathe12/movie-listing

onSetGenre(data) {
    let index = findIndex(this.movies, function(m) {
      return m.id == data.movieId;
    });

    if (index >= 0) {
      if (!this.movies[index].genres) {
        this.movies[index].genres = [];
      }

      this.movies[index].genres.push(data.genre);
    }
  }
origin: SaraBlich/React-start

updateInfo(name, value, id)
 {
  let tempApts = this.state.myAppointment;
  let aptIndex = findIndex(this.state.myAppointment, {
   aptId: id
  });
  tempApts[aptIndex][name] = value;
  this.setState({
   myAppointment: tempApts
  });
 }
origin: mariobermudezjr/ecommerce-react-graphql-stripe

Object.keys(modifiedData).reduce((acc, key) => {
   if (isEmpty(get(modifiedData, key)) && !isBoolean(get(modifiedData, key))) {
    acc.push({ name: key, errors: [{ id: 'components.Input.error.validation.required' }] });
   }

   if (!isEmpty(get(modifiedData, 'password')) && !isEmpty(get(modifiedData, 'confirmPassword')) && findIndex(acc, ['name', 'confirmPassword']) === -1) {
    if (modifiedData.password.length < 6) {
     acc.push({ name: 'password', errors: [{ id: 'users-permissions.components.Input.error.password.length' }] });
    }
    
    if (get(modifiedData, 'password') !== get(modifiedData, 'confirmPassword')) {
     acc.push({ name: 'confirmPassword', errors: [{ id: 'users-permissions.components.Input.error.password.noMatch' }] });
    }
   }

   return acc;
  }, [])
origin: joedunu/react-redux-playground

const mapStateToProps = (state) => {
 const editingUserIndex = findIndex(state.users, (user) => {
  return state.appDetails.editingUser === user.id
 })

 return {
  initialValues: state.users[editingUserIndex]
 }
}
origin: mariobermudezjr/ecommerce-react-graphql-stripe

componentDidMount() {
  const environmentIndex = this.props.envParams ? findIndex(this.props.environments, ['name', this.props.envParams]) : 0;
  this.setState({ environmentIndex });
 }
origin: jquatier/eureka-js-client

deleteInstance(cache, instance) {
  const vipAddresses = this.splitVipAddress(instance.vipAddress);
  const appName = instance.app.toUpperCase();
  vipAddresses.forEach((vipAddress) => {
   const index = findIndex(cache.vip[vipAddress], findInstance(instance));
   if (index > -1) cache.vip[vipAddress].splice(index, 1);
  });
  const index = findIndex(cache.app[appName], findInstance(instance));
  if (index > -1) cache.app[appName].splice(cache.vip[instance.vipAddress], 1);
 }
origin: sreenathe12/movie-listing

onSetMovie(movie) {
    let index = findIndex(this.movies, function(m) {
      return m.id == movie.id;
    });

    if (index >= 0) {
      this.movies[index] = movie;
    }
  }
origin: zetekla/react-diff-view

const findChangeBlocks = changes => {
  const start = findIndex(changes, change => !change.isNormal);

  if (start === -1) {
    return [];
  }

  const end = findIndex(changes, change => change.isNormal, start);

  if (end === -1) {
    return [changes.slice(start)];
  }

  return [
    changes.slice(start, end),
    ...findChangeBlocks(changes.slice(end))
  ];
}
origin: mariobermudezjr/ecommerce-react-graphql-stripe

export function checkFormValidity(formData, formValidations) {
 const errors = [];
 forEach(formData, (value, key) => {
  const validationValue = formValidations[findIndex(formValidations, ['name', key])];

  if (!isUndefined(validationValue)) {
   const inputErrors = validate(value, validationValue.validations);
   if (!isEmpty(inputErrors)) {
    errors.push({ name: key, errors: inputErrors });
   }

  }

 });

 return errors;
}
lodash(npm)findIndex

Most used lodash functions

  • LoDashStatic.map
    Creates an array of values by running each element in collection through iteratee. The iteratee is
  • LoDashStatic.isEmpty
    Checks if value is empty. A value is considered empty unless it’s an arguments object, array, string
  • LoDashStatic.forEach
    Iterates over elements of collection invoking iteratee for each element. The iteratee is invoked wit
  • LoDashStatic.find
    Iterates over elements of collection, returning the first element predicate returns truthy for.
  • LoDashStatic.pick
    Creates an object composed of the picked `object` properties.
  • LoDashStatic.get,
  • LoDashStatic.isArray,
  • LoDashStatic.filter,
  • LoDashStatic.merge,
  • LoDashStatic.isString,
  • LoDashStatic.isFunction,
  • LoDashStatic.assign,
  • LoDashStatic.extend,
  • LoDashStatic.includes,
  • LoDashStatic.keys,
  • LoDashStatic.cloneDeep,
  • LoDashStatic.uniq,
  • LoDashStatic.isObject,
  • LoDashStatic.omit

Popular in JavaScript

  • path
  • postcss
  • commander
    the complete solution for node.js command-line programs
  • minimatch
    a glob matcher in javascript
  • cheerio
    Tiny, fast, and elegant implementation of core jQuery designed specifically for the server
  • moment
    Parse, validate, manipulate, and display dates
  • bluebird
    Full featured Promises/A+ implementation with exceptionally good performance
  • webpack
    Packs CommonJs/AMD modules for the browser. Allows to split your codebase into multiple bundles, which can be loaded on demand. Support loaders to preprocess files, i.e. json, jsx, es7, css, less, ... and your custom stuff.
  • semver
    The semantic version parser used by npm.
  • Top plugins for WebStorm
    The challenge is finding the best plugins for JavaScript development on Intellij IDEs. Who wants to sit there and go over hundreds of plugins to pick the best?
Codota Logo
  • Products

    Search for Java codeSearch for JavaScript codeEnterprise
  • IDE Plugins

    IntelliJ IDEAWebStormAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimAtomGoLandRubyMineEmacsJupyter
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogCodota Academy Plugin user guide Terms of usePrivacy policyJavascript Code Index
Get Codota for your IDE now