A read-only collection.

Type Parameters

  • T

Hierarchy (view full)

Constructors

Properties

_handles: Handles<unknown, ResourceHandle>
@eventTypes: CollectionEvents<T>

Do not directly reference this property. Use EventNames and EventTypes helpers from @arcgis/core/Evented.

declaredClass: string = "esri.core.Collection"

The declared class name. This is always "esri.core.Collection" for compatibility with Esri's API.

Accessors

  • get _collection(): Collection<T>
  • The underlying collection that this class delegates to.

    Returns Collection<T>

  • set _collection(collection): void
  • Parameters

    • collection: Collection<T>

    Returns void

  • get destroyed(): boolean
  • Whether the collection has been destroyed.

    Returns boolean

  • set destroyed(value): void
  • Parameters

    • value: boolean

    Returns void

  • get initialized(): boolean
  • Whether the collection has been initialized.

    Returns boolean

  • set initialized(value): void
  • Set to true once the initialize function has executed.

    Parameters

    • value: boolean

    Returns void

  • get length(): number
  • The number of items in the collection.

    Returns number

Methods

  • Parameters

    • propertyName: string

    Returns any

    • Unsupported on CollectionProxy.
  • Type Parameters

    • T

    Parameters

    • propertyName: string

    Returns T

  • Type Parameters

    • T

    Parameters

    • propertyName: string
    • value: T

    Returns this

    • Unsupported on CollectionProxy.
  • Adds a single item to the collection.

    Parameters

    • _item: T
    • Optional_index: number

    Returns this

  • Adds multiple items to the collection.

    Parameters

    • items: ReadonlyArrayOrCollection<T>

      An array or collection of items to add.

    • Optionalindex: number

      Zero-based index of where in the collection to add the items. If not specified, the items will be added at the end.

    Returns this

  • Returns the item at the specified index.

    Parameters

    • index: number

      Zero-based index of the item in the Collection to retrieve.

    Returns T

    The item in the Collection stored at the specified index.

  • Creates a deep clone of the Collection. To create a shallow clone of the collection, use slice().

    Returns Collection<T>

  • Creates a new Collection containing the items in the original Collection joined with the items in the input array or Collection.

    Parameters

    • value: Collection<T> | T[]

      The array or Collection to append to the existing Collection.

    Returns Collection<T>

  • Removes all event listeners and destroys the collection.

    Returns void

  • Parameters

    • callback: ItemCallback<T>
    • OptionalthisArg: any

    Returns void

  • Determines whether all items in the Collection pass a test defined by callback. Each item in the Collection is passed into the callback until one returns a value of false.

    Parameters

    Returns boolean

  • Filters the Collection's items based on a test defined by the callback function. Each item is passed into the callback function, which returns true if the item passes the test and false if it does not.

    Parameters

    • callback: ItemTestCallback<T>

      The function that defines a test for determining whether to return the item in a new Collection.

    Returns Collection<T>

  • Returns an item in the Collection if that item passes a test as defined in the callback function. Each item is passed into the callback function, which returns true if the item passes the test and false if it does not.

    Parameters

    • callback: ItemTestCallback<T>

      The testing function that will assess each item in the Collection. Returns true if an item passes the test and false if it fails.

    Returns T

  • Returns the index of an item in the Collection if that item passes a test as defined in the callback function. Each item is passed into the callback function, which returns true if the item passes the test and false if it does not.

    Parameters

    • callback: ItemTestCallback<T>

      The testing function that will assess each item in the Collection. Returns true if an item passes the test and false if it fails.

    Returns number

    Returns the index of the Collection item that satisfies the test function. If an item fails the test, -1 is returned.

  • Flattens a hierarchical Collection containing at least one child collection. Each item in the collection is passed into the callback function, which should check for child collections specified by the developer. A flat collection of all items (parent and children) is returned.

    Parameters

    • callback: ((item: T, index: number) => Collection<T> | T[])

      A function that will assess each item in the Collection.

        • (item, index): Collection<T> | T[]
        • Parameters

          • item: T
          • index: number

          Returns Collection<T> | T[]

    Returns Collection<T>

  • Executes the input function for each item in the Collection.

    Parameters

    • callback: ItemCallback<T>

      The function to call for each item in the Collection.

    Returns void

  • Type Parameters

    • T

    Parameters

    • propertyPath: string

    Returns T

    • Unsupported on CollectionProxy.
  • Parameters

    • propertyPath: string

    Returns unknown

    • Unsupported on CollectionProxy.
  • Returns the item at the specified index.

    Parameters

    • index: number

      Zero-based index of the item in the Collection to retrieve.

    Returns T

    The item in the Collection stored at the specified index.

  • Type Parameters

    • T

    Parameters

    • OptionalgroupKey: Exclude<T, ResourceHandle>

    Returns boolean

  • Tests if an item is present in the Collection.

    Parameters

    • searchElement: T

      The item to search for in the collection.

    Returns boolean

  • Returns the index of an element in the collection.

    Parameters

    • searchElement: T

      Item to search for in the collection.

    • OptionalfromIndex: number

      Use if you don't want to search the whole collection or you don't want to search from the start.

    Returns number

  • Creates a string representation of the items in the Collection.

    Parameters

    • Optionalseparator: string

      The separator used between each item in the final string. The default is ",".

    Returns string

  • Returns the last index of an element in the collection.

    Parameters

    • searchElement: T

      Item to search for in the collection.

    • OptionalfromIndex: number

      Use if you don't want to search the whole collection, or you don't want to search from the end.

    Returns number

    The location of the last match found in the collection, or -1 if there is no match.

  • Passes each Collection item into the callback function and returns a new array of the returned values.

    Type Parameters

    • U

    Parameters

    • callback: ItemMapCallback<T, U>

      The function that processes each item in the Collection and returns a new value at the same index of the original item.

    Returns Collection<U>

  • Removes the last item from the collection and returns it.

    Returns T

  • Adds an item to the end of the collection.

    Parameters

    • item: T

      The item to add.

    Returns number

  • Reduces all items in the collection (from left to right) into a single variable using callback.

    Type Parameters

    • U

    Parameters

    • callback: ItemReduceCallback<T, U>

      The function that processes each item in the Collection and appends it to the previous item.

    • OptionalinitialValue: U

      Item to use as the first element to process in callback.

    Returns U

  • Reduces all items in the collection (from right to left) into a single variable using callback.

    Type Parameters

    • U

    Parameters

    • callback: ItemReduceCallback<T, U>

      The function that processes each item in the Collection and appends it to the previous item.

    • OptionalinitialValue: U

      Item to use as the first element to process in callback.

    Returns U

  • Removes an item from the collection.

    Parameters

    • item: T

      The item to remove.

    Returns T

  • Removes an item from the collection at a specified index.

    Parameters

    • _index: number

    Returns T

  • Type Parameters

    • T

    Parameters

    • OptionalgroupKey: Exclude<T, ResourceHandle>

    Returns void

  • Removes each item in the input array. If an item is present multiple times in the collection, only the first occurrence is removed.

    Parameters

    • items: ReadonlyArrayOrCollection<T>

      The items to remove.

    Returns T[]

  • Moves an item in the Collection to a specified index. The change event is fired after an item is moved in the Collection.

    Parameters

    • _item: T
    • _index: number

    Returns T

  • Type Parameters

    • T

    Parameters

    • propertyPath: string
    • value: T

    Returns this

    • Unsupported on CollectionProxy.
  • Parameters

    • properties: HashMap<unknown>

    Returns this

    • Unsupported on CollectionProxy.
  • Removes the first item from the collection (at index 0), and returns it. The remaining items of the collection are then shifted down one index from their previous location.

    Returns T

  • Creates a new Collection comprised of a portion of the original Collection.

    Parameters

    • Optionalbegin: number

      The index of the first item to extract.

    • Optionalend: number

      The index of the last item to extract.

    Returns Collection<T>

  • Determines whether an item in the Collection passes a test defined by callback. Each item in the Collection is passed into the callback until one returns a value of true.

    Parameters

    • callback: ItemTestCallback<T>

      The function that defines the test for each Collection item.

    Returns boolean

  • Sorts the Collection in place.

    Parameters

    • Optional_compareFunction: ((a: T, b: T) => number)
        • (a, b): number
        • Parameters

          Returns number

    Returns this

  • Removes existing items and/or adds new items to the collection.

    Parameters

    • _start: number
    • _deleteCount: number
    • Rest..._items: T[]

    Returns T[]

    An array of the deleted items formerly part of the collection.

  • Returns a new array object containing the Collection's items.

    Returns T[]

  • Adds an item to the beginning of the collection.

    Parameters

    • item: T

      The item to add.

    Returns number

  • Parameters

    • path: string | string[]
    • callback: ((newValue: any, oldValue: any, propertyName: string, target: any) => void)
        • (newValue, oldValue, propertyName, target): void
        • Parameters

          • newValue: any
          • oldValue: any
          • propertyName: string
          • target: any

          Returns void

    • Optionalsync: boolean

    Returns IHandle

    • Unsupported on CollectionProxy.