Skip to main content

ArrayIndexed <T>

Extension of the default Array class that adds indexing methods

Hierarchy

  • Array<T>
    • ArrayIndexed

Index

Constructors

constructor

  • new ArrayIndexed<T>(indexKey: string, items?: any[], options?: { autoId?: boolean; unique?: boolean }): ArrayIndexed<T>
  • Type parameters

    • T

    Parameters

    • indexKey: string
    • optionalitems: any[]
    • optionaloptions: { autoId?: boolean; unique?: boolean }

    Returns ArrayIndexed<T>

Properties

dict

dict: {}

Type declaration

  • [key string]: any

key

key: string

nextId

nextId: number

options

options: { autoId: boolean; unique: boolean }

Type declaration

  • autoId: boolean
  • unique: boolean

Methods

clear

  • clear(): this
  • Returns this

delete

  • delete(id: string | number): void
  • Parameters

    • id: string | number

    Returns void

deleteById

  • deleteById(id: string | number): void
  • Parameters

    • id: string | number

    Returns void

findById

  • findById(id: string | number): T
  • Parameters

    • id: string | number

    Returns T

get

  • get(id: string | number): any
  • Parameters

    • id: string | number

    Returns any

pop

  • pop(): T
  • Returns T

push

  • push(...items: T[]): number
  • Parameters

    • rest...items: T[]

    Returns number

reindex

  • reindex(): void
  • Returns void

sort

  • sort(compareFn?: (a: T, b: T) => number): this
  • Parameters

    • optionalcompareFn: (a: T, b: T) => number

    Returns this

splice

  • splice(start: number, deleteCount?: number): T[]
  • Parameters

    • start: number
    • optionaldeleteCount: number

    Returns T[]

toObject

  • toObject(): Record<string, T>
  • Returns Record<string, T>

update

  • update(data: {}): boolean | T
  • Parameters

    • data: {}

    Returns boolean | T