Skip to content

⬅️ Back to Table of Contents

📄 index.ts

📊 Analysis Summary

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

📚 Table of Contents

🛠️ File Location:

📂 packages/shared/useArrayMap/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

useArrayMap(list: MaybeRefOrGetter<MaybeRefOrGetter<T>[]>, fn: (element: T, index: number, array: T[]) => U): UseArrayMapReturn<U>

Code
export function useArrayMap<T, U = T>(
  list: MaybeRefOrGetter<MaybeRefOrGetter<T>[]>,
  fn: (element: T, index: number, array: T[]) => U,
): UseArrayMapReturn<U> {
  return computed(() => toValue(list).map(i => toValue(i)).map(fn))
}
  • JSDoc:

    /**
     * Reactive `Array.map`
     *
     * @see https://vueuse.org/useArrayMap
     * @param list - the array was called upon.
     * @param fn - a function that is called for every element of the given `list`. Each time `fn` executes, the returned value is added to the new array.
     *
     * @returns a new array with each element being the result of the callback function.
     */
    

  • Parameters:

  • list: MaybeRefOrGetter<MaybeRefOrGetter<T>[]>
  • fn: (element: T, index: number, array: T[]) => U
  • Return Type: UseArrayMapReturn<U>
  • Calls:
  • computed (from vue)
  • toValue(list).map(i => toValue(i)).map

Type Aliases

UseArrayMapReturn<T = any = any>

type UseArrayMapReturn<T = any = any> = ComputedRef<T[]>;