📄 useArrayFindLast¶
📊 Analysis Summary¶
| Metric | Count |
|---|---|
| 🔧 Functions | 2 |
| 📦 Imports | 4 |
| 🟢 Vue Composition API | 1 |
| 📑 Type Aliases | 1 |
📚 Table of Contents¶
🛠️ File Location:¶
📂 packages/shared/useArrayFindLast/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¶
useArrayFindLast(list: MaybeRefOrGetter<MaybeRefOrGetter<T>[]>, fn: (element: T, index: number, array: Mayb…): UseArrayFindLastReturn<T>¶
Reactive Array.findLast
Parameters:
listany: the array was called upon.fnany: a function to test each element.
Returns: undefined
the last element in the array that satisfies the provided testing function. Otherwise, undefined is returned.
See: https://vueuse.org/useArrayFindLast
Tags: @__NO_SIDE_EFFECTS__
Raw JSDoc
/**
* Reactive `Array.findLast`
*
* @see https://vueuse.org/useArrayFindLast
* @param list - the array was called upon.
* @param fn - a function to test each element.
*
* @returns the last element in the array that satisfies the provided testing function. Otherwise, undefined is returned.
*
* @__NO_SIDE_EFFECTS__
*/
Calls:
computed (from vue)toValue (from vue)findLastfntoValue(list) .findLast
Code
export function useArrayFindLast<T>(
list: MaybeRefOrGetter<MaybeRefOrGetter<T>[]>,
fn: (element: T, index: number, array: MaybeRefOrGetter<T>[]) => boolean,
): UseArrayFindLastReturn<T> {
return computed(() =>
toValue<T | undefined>(
!Array.prototype.findLast
? findLast(toValue(list), (element, index, array) => fn(toValue(element), index, array))
: toValue(list)
.findLast((element, index, array) => fn(toValue(element), index, array)),
))
}
findLast(arr: T[], cb: (element: T, index: number, array: T[])…): T | undefined¶
Parameters:
arrT[]cb(element: T, index: number, array: T[]) => boolean
Returns: T | undefined
Calls:
cb
Code
Type Aliases¶
UseArrayFindLastReturn<T = any>¶
Generated by Syntax Scribe