Skip to content

⬅️ Back to Table of Contents

📄 useArrayFindIndex

📊 Analysis Summary

Metric Count
🔧 Functions 1
📦 Imports 4
🟢 Vue Composition API 1
📑 Type Aliases 1

📚 Table of Contents

🛠️ File Location:

📂 packages/shared/useArrayFindIndex/index.ts

📦 Imports

Name Source
ComputedRef vue
MaybeRefOrGetter vue
computed vue
toValue vue

Vue Composition API

Name Type Reactive Variables Composables
computed computed none none

Functions

useArrayFindIndex(list: MaybeRefOrGetter<MaybeRefOrGetter<T>[]>, fn: (element: T, index: number, array: Mayb…): UseArrayFindIndexReturn

Reactive Array.findIndex

Parameters:

  • list any: the array was called upon.
  • fn any: a function to test each element.

Returns: undefined the index of the first element in the array that passes the test. Otherwise, "-1".

See: https://vueuse.org/useArrayFindIndex

Tags: @__NO_SIDE_EFFECTS__

Raw JSDoc
/**
 * Reactive `Array.findIndex`
 *
 * @see https://vueuse.org/useArrayFindIndex
 * @param list - the array was called upon.
 * @param fn - a function to test each element.
 *
 * @returns the index of the first element in the array that passes the test. Otherwise, "-1".
 *
 * @__NO_SIDE_EFFECTS__
 */

Calls:

  • computed (from vue)
  • toValue(list).findIndex
  • fn
  • toValue (from vue)
Code
export function useArrayFindIndex<T>(
  list: MaybeRefOrGetter<MaybeRefOrGetter<T>[]>,
  fn: (element: T, index: number, array: MaybeRefOrGetter<T>[]) => unknown,
): UseArrayFindIndexReturn {
  return computed(() => toValue(list).findIndex((element, index, array) => fn(toValue(element), index, array)))
}

Type Aliases

UseArrayFindIndexReturn

type UseArrayFindIndexReturn = ComputedRef<number>;

Generated by Syntax Scribe