Options
All
  • Public
  • Public/Protected
  • All
Menu

Class ArrayMap<T>

Type parameters

Hierarchy

  • ArrayMap

Index

Constructors

constructor

Properties

Private _alias

_alias: string

Private _data

_data: T[] = []

Private _events

_events: ArrayMapEvents<T>

Private _getKey

_getKey: ArrayMapGetKey<T>

Private _key

_key: string

Private _keys

_keys: string[]

Private dataMap

dataMap: Props<number>

Private newMap

newMap: function

Type declaration

Static defaultKey

defaultKey: "id" = "id"

Accessors

data

  • get data(): T[]
  • set data(data: T[]): void

first

  • get first(): T
  • set first(item: T): void

last

  • get last(): T
  • set last(item: T): void

length

  • get length(): number

nameOfKey

  • get nameOfKey(): string

Methods

clone

concat

get

  • get(key: number | string): T

getKey

  • getKey(item: T): string

indexOf

  • indexOf(searchElement: T | string, fromIndex?: number): number
  • Returns the index of the first occurrence of a value in an array.

    Parameters

    • searchElement: T | string

      The value to locate in the array.

    • Optional fromIndex: number

      The array index at which to begin the search. If fromIndex is omitted, the search starts at index 0.

    Returns number

join

  • join(separator: string, get?: function): string
  • Adds all the elements of an array separated by the specified separator string.

    Parameters

    • separator: string

      A string used to separate one element of an array from the next in the resulting String. If omitted, the array elements are separated with a comma.

    • Optional get: function
        • (item: T, index?: number): string
        • Parameters

          • item: T
          • Optional index: number

          Returns string

    Returns string

key

  • key(value: T | number): string

lastIndexOf

  • lastIndexOf(searchElement: T | string, fromIndex?: number): number
  • Returns the index of the last occurrence of a specified value in an array.

    Parameters

    • searchElement: T | string

      The value to locate in the array.

    • Optional fromIndex: number

      The array index at which to begin the search. If fromIndex is omitted, the search starts at the last index in the array.

    Returns number

onCreated

  • onCreated(index: number, key: any, value: T): void

onDeleted

  • onDeleted(value: T[]): void

onInit

  • onInit(data: T[]): void

onUpdated

  • onUpdated(index: number, key: any, value: T, oldValue: T): void

pop

  • pop(): T

push

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

refresh

  • refresh(): void

remove

  • remove(value: number | string | T): T | undefined

removeByIndex

  • removeByIndex(value: number): T | undefined

removeByKey

  • removeByKey(value: string): T

reverse

set

  • set(key: number | string, value: T): boolean

setKey

  • setKey(key: string, item: T): T

shift

  • shift(): T

slice

  • slice(start?: number, end?: number): ArrayMap<T>
  • Returns a section of an array.

    Parameters

    • Optional start: number

      The beginning of the specified portion of the array.

    • Optional end: number

      The end of the specified portion of the array.

    Returns ArrayMap<T>

sort

  • sort(compareFn?: function): ArrayMap<T> | any
  • Sorts an array.

    Parameters

    • Optional compareFn: function

      The name of the function used to determine the order of the elements. If omitted, the elements are sorted in ascending, ASCII character order.

        • (a: T, b: T): number
        • Parameters

          • a: T
          • b: T

          Returns number

    Returns ArrayMap<T> | any

splice

  • splice(start: number, deleteCount?: number): ArrayMap<T> | undefined
  • Removes elements from an array and, if necessary, inserts new elements in their place, returning the deleted elements.

    Parameters

    • start: number

      The zero-based location in the array from which to start removing elements.

    • Optional deleteCount: number

      The number of elements to remove.

    Returns ArrayMap<T> | undefined

unshift

  • unshift(...items: (T | T[])[]): number
  • Inserts new elements at the start of an array.

    Parameters

    • Rest ...items: (T | T[])[]

      Elements to insert at the start of the Array.

    Returns number

Private upsert

  • upsert(item: T, fn: function): boolean
  • Parameters

    • item: T
    • fn: function
        • (item: T): number
        • Parameters

          • item: T

          Returns number

    Returns boolean

Static assertKey

  • assertKey<T>(map: ArrayMap<T>, item: T | number): string

Static getKey

  • getKey<T>(map: ArrayMap<T>, item: T): string

Static remove

  • remove<T>(map: ArrayMap<T>, value: number | string | T): T | undefined

Static removeByIndex

  • removeByIndex<T>(map: ArrayMap<T>, value: number): T | undefined

Static setKey

  • setKey<T>(map: ArrayMap<T>, key: string, item: T): T

Generated using TypeDoc