Class Collection<CollectionItem>

Collection of items

Type Parameters

  • CollectionItem

Hierarchy

Implements

  • Iterable<CollectionItem>

Constructors

Properties

items: CollectionItem[]

Methods

  • Returns Iterator<CollectionItem, any, undefined>

  • Add items at the end

    Parameters

    • Rest ...items: CollectionItem[]

    Returns number

    the index of the last added item

  • The filter() method creates a new array with all elements that pass the test implemented by the provided function.

    Parameters

    • predicate: ((value, index, obj) => unknown)

      find calls predicate once for each element of the array, in ascending order, until it finds one where predicate returns true. If such an element is found, find immediately returns that element value. Otherwise, find returns undefined.

        • (value, index, obj): unknown
        • Parameters

          • value: CollectionItem
          • index: number
          • obj: CollectionItem[]

          Returns unknown

    Returns CollectionItem[]

    CollectionItem | undefined

  • Returns the value of the first element in the array where predicate is true, and undefined otherwise.

    Parameters

    • predicate: ((value, index, obj) => unknown)

      find calls predicate once for each element of the array, in ascending order, until it finds one where predicate returns true. If such an element is found, find immediately returns that element value. Otherwise, find returns undefined.

        • (value, index, obj): unknown
        • Parameters

          • value: CollectionItem
          • index: number
          • obj: CollectionItem[]

          Returns unknown

    Returns undefined | CollectionItem

    CollectionItem | undefined

  • Returns the index of the first element in the array where predicate is true, and -1 otherwise.

    Parameters

    • predicate: ((value, index, obj) => unknown)

      find calls predicate once for each element of the array, in ascending order, until it finds one where predicate returns true. If such an element is found, findIndex immediately returns that element index. Otherwise, findIndex returns -1.

        • (value, index, obj): unknown
        • Parameters

          • value: CollectionItem
          • index: number
          • obj: CollectionItem[]

          Returns unknown

    Returns number

  • Return first item

    Returns undefined | CollectionItem

  • Performs the specified action for each element in an array.

    Parameters

    • callbackfn: ((value, index, array) => void)

      A function that accepts up to three arguments. forEach calls the callbackfn function one time for each element in the array.

        • (value, index, array): void
        • Parameters

          • value: CollectionItem
          • index: number
          • array: CollectionItem[]

          Returns void

    • Optional thisArg: any

      An object to which the this keyword can refer in the callbackfn function. If thisArg is omitted, undefined is used as the this value.

    Returns void

  • Get an item at the given index

    Parameters

    • index: number

    Returns undefined | CollectionItem

  • Check if the given item is present

    Parameters

    • item: CollectionItem

    Returns boolean

  • Find the index of an item. Returns -1 if not found.

    Parameters

    • item: CollectionItem

    Returns number

  • Insert items at the given index

    Parameters

    • index: number

      Use negative indexes to insert from the end. For example -1 inserts before the last item.

    • Rest ...items: CollectionItem[]

    Returns number

  • return the last item

    Returns undefined | CollectionItem

  • Remove items

    Parameters

    • Rest ...items: CollectionItem[]

    Returns void

  • Remove an item

    Parameters

    • index: number

      Item index

    Returns boolean

  • Replace the collection with an array

    Parameters

    • Rest ...items: CollectionItem[]

    Returns void

Generated using TypeDoc