Interface IArrayExtensions<TSource>

Type Parameters

  • TSource

Hierarchy

  • IArrayExtensions

Methods

  • Removes all items from the array. Original array is mutated.

    Example

    const arr = [1, 2, 3];
    arr.clear(); // arr is now []

    Returns void

  • Inserts an item at the given index into the array. Existing items at and after the index will be pushed back. No items will be deleted. Original array is mutated.

    Example

    const arr = [1, 2, 3];
    arr.insert(1, 5); // arr is now [1, 5, 2, 3]

    Parameters

    • index: number

      The index of which to insert the item.

    • item: TSource

      The item to insert.

    Returns void

  • Inserts an item at the given index into the array. Existing items at and after the index will be pushed back. No items will be deleted. Original array is mutated. *

    Example

    const arr = [1, 2, 3];
    arr.insertRange(1, [5, 6]); // arr is now [1, 5, 6, 2, 3]

    Parameters

    • index: number

      The index of which to start the insertion.

    • collection: Iterable<TSource>

      The items to insert.

    Returns void

  • Removes an item from the array. Original array is mutated.

    Example

    const numbers = [1, 2, 3];
    const res = numbers.remove(2); // numbers is modified in place. res is true because element was in the array.

    Returns

    true if item was found and removed from array. False if item was not found in the array.

    Parameters

    • item: TSource

      Item to remove from array.

    Returns boolean

  • Removes all items from the array that pass the predicate. Original array is mutated.

    Example

    const arr = [1, 2, 3, 4];
    arr.removeAll(x => x > 2); // arr is now [1, 2]

    Returns

    The number of removed items.

    Parameters

    • predicate: ((item: TSource, index: number) => boolean)

      The predicate to test for a condition.

        • (item: TSource, index: number): boolean
        • Parameters

          • item: TSource
          • index: number

          Returns boolean

    Returns number

Generated using TypeDoc