Skip to content

⬅️ Back to Table of Contents

📄 index.ts

📊 Analysis Summary

Metric Count
🔧 Functions 3
📦 Imports 6
📊 Variables & Constants 2
🟢 Vue Composition API 1
📐 Interfaces 1
📑 Type Aliases 2

📚 Table of Contents

🛠️ File Location:

📂 packages/core/useSorted/index.ts

📦 Imports

Name Source
MaybeRefOrGetter vue
Ref vue
computed vue
isRef vue
toValue vue
watchEffect vue

Variables & Constants

Name Type Kind Value Exported
compareFn UseSortedCompareFn let/var defaultCompare
options UseSortedOptions let/var {}

Vue Composition API

Name Type Reactive Variables Composables
computed computed none none

Functions

defaultSortFn(source: T[], compareFn: UseSortedCompareFn<T>): T[]

Code
<T>(source: T[], compareFn: UseSortedCompareFn<T>): T[] => source.sort(compareFn)
  • Parameters:
  • source: T[]
  • compareFn: UseSortedCompareFn<T>
  • Return Type: T[]
  • Calls:
  • source.sort

defaultCompare(a: number, b: number): number

Code
(a, b) => a - b
  • Parameters:
  • a: number
  • b: number
  • Return Type: number

useSorted(source: MaybeRefOrGetter<T[]>, compareFn: UseSortedCompareFn<T>): Ref<T[]>

Code
export function useSorted<T = any>(source: MaybeRefOrGetter<T[]>, compareFn?: UseSortedCompareFn<T>): Ref<T[]>
  • JSDoc:

    /**
     * reactive sort array
     *
     * @see https://vueuse.org/useSorted
     */
    

  • Parameters:

  • source: MaybeRefOrGetter<T[]>
  • compareFn: UseSortedCompareFn<T>
  • Return Type: Ref<T[]>

Interfaces

UseSortedOptions<T = any>

Interface Code
export interface UseSortedOptions<T = any> {
  /**
   * sort algorithm
   */
  sortFn?: UseSortedFn<T>
  /**
   * compare function
   */
  compareFn?: UseSortedCompareFn<T>
  /**
   * change the value of the source array
   * @default false
   */
  dirty?: boolean
}

Properties

Name Type Optional Description
sortFn UseSortedFn<T>
compareFn UseSortedCompareFn<T>
dirty boolean

Type Aliases

UseSortedCompareFn<T = any = any>

type UseSortedCompareFn<T = any = any> = (a: T, b: T) => number;

UseSortedFn<T = any = any>

type UseSortedFn<T = any = any> = (arr: T[], compareFn: UseSortedCompareFn<T>) => T[];