Tabnine Logo For Javascript
findIndex
Code IndexAdd Tabnine 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

  • through2
    A tiny wrapper around Node.js streams.Transform (Streams2/3) to avoid explicit subclassing noise
  • winston
    A logger for just about everything.
  • http
  • mocha
    simple, flexible, fun test framework
  • cheerio
    Tiny, fast, and elegant implementation of core jQuery designed specifically for the server
  • minimist
    parse argument options
  • chalk
    Terminal string styling done right
  • moment
    Parse, validate, manipulate, and display dates
  • path
  • From CI to AI: The AI layer in your organization
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogTabnine AcademyTerms of usePrivacy policyJavascript Code Index
Get Tabnine for your IDE now