Class ArrayEnumerable<TSource>

Array backed Enumerable

Type Parameters

  • TSource

Hierarchy

Indexable

Constructors

Methods

  • Determines whether all elements of a sequence satisfy a condition.

    Parameters

    • predicate: (x: TSource) => boolean

      A function to test each element for a condition.

    Returns boolean

    true if every element of the source sequence passes the test in the specified predicate, or if the sequence is empty; otherwise, false.

  • Determines whether all elements of a sequence satisfy a condition.

    Parameters

    • predicate: (x: TSource) => Promise<boolean>

      An async function to test each element for a condition.

    Returns Promise<boolean>

    true if every element of the source sequence passes the test in the specified predicate, or if the sequence is empty; otherwise, false.

  • Determines whether a sequence contains any elements. If predicate is specified, determines whether any element of a sequence satisfies a condition.

    Parameters

    • Optionalpredicate: (x: TSource) => boolean

      A function to test each element for a condition.

    Returns boolean

    true if the source sequence contains any elements or passes the test specified; otherwise, false.

  • Determines whether any element of a sequence satisfies a condition.

    Parameters

    • predicate: (x: TSource) => Promise<boolean>

      An async function to test each element for a condition.

    Returns Promise<boolean>

    true if the source sequence contains any elements or passes the test specified; otherwise, false.

  • Computes the average of a sequence of number values.

    Parameters

    Returns number

    The average of the sequence of values.

    source contains no elements.

  • Computes the average of a sequence of values that are obtained by invoking a transform function on each element of the input sequence.

    Parameters

    • selector: (x: TSource) => number

      A transform function to apply to each element.

    Returns number

    The average of the sequence of values.

    source contains no elements.

  • Computes the average of a sequence of values that are obtained by invoking a transform function on each element of the input sequence.

    Parameters

    • selector: (x: TSource) => Promise<number>

      An async transform function to apply to each element.

    Returns Promise<number>

    The average of the sequence of values.

    source contains no elements.

  • Splits the elements of a sequence into chunks of size at most size.

    Parameters

    • size: number

      The maximum size of each chunk.

    Returns IEnumerable<TSource[]>

    An IEnumerable that contains the elements the input sequence split into chunks of size size.

  • Determines whether a sequence contains a specified element by using the specified or default IEqualityComparer.

    Parameters

    Returns boolean

    true if the source sequence contains an element that has the specified value; otherwise, false.

  • Determines whether a sequence contains a specified element by using the specified or default IEqualityComparer.

    Parameters

    Returns Promise<boolean>

    true if the source sequence contains an element that has the specified value; otherwise, false.

  • Returns the number of elements in a sequence or represents how many elements in the specified sequence satisfy a condition if the predicate is specified.

    Parameters

    • Optionalpredicate: (x: TSource) => boolean

      A function to test each element for a condition. Optional.

    Returns number

    The number of elements in the input sequence.

  • Returns the number of elements in a sequence or represents how many elements in the specified sequence satisfy a condition if the predicate is specified.

    Parameters

    • predicate: (x: TSource) => Promise<boolean>

      A function to test each element for a condition.

    Returns Promise<number>

    The number of elements in the input sequence.

  • Returns the elements of an IEnumerable, or a default valued singleton collection if the sequence is empty.

    Parameters

    • defaultValue: TSource

      The value to return if the sequence is empty.

    Returns IEnumerable<TSource>

    An IEnumerable that contains defaultValue if source is empty; otherwise, source.

  • Returns the element at a specified index in a sequence.

    Parameters

    • index: number

      The zero-based index of the element to retrieve.

    Returns TSource

    The element at the specified position in the source sequence.

    index is less than 0 or greater than or equal to the number of elements in source.

  • Returns the element at a specified index in a sequence or a default value if the index is out of range.

    Parameters

    • index: number

      The zero-based index of the element to retrieve.

    Returns null | TSource

    null if the index is outside the bounds of the source sequence; otherwise, the element at the specified position in the source sequence.

  • Produces the set difference of two sequences by using the comparer provided or EqualityComparer to compare values.

    Parameters

    • second: Iterable<TSource>

      An IEnumerable whose elements that also occur in the first sequence will cause those elements to be removed from the returned sequence.

    • Optionalcomparer: IEqualityComparer<TSource>

      An IEqualityComparer to compare values. Optional.

    Returns IEnumerable<TSource>

    A sequence that contains the set difference of the elements of two sequences.

  • Returns first element in sequence that satisfies predicate otherwise returns the first element in the sequence.

    Parameters

    • Optionalpredicate: (x: TSource) => boolean

      A function to test each element for a condition. Optional.

    Returns TSource

    The first element in the sequence or the first element that passes the test in the specified predicate function.

    No elements in Iteration matching predicate

  • Returns the first element in a sequence that satisfies a specified condition.

    Parameters

    • predicate: (x: TSource) => Promise<boolean>

      A function to test each element for a condition.

    Returns Promise<TSource>

    The first element in the sequence that passes the test in the specified predicate function.

    No elements in Iteration matching predicate

  • Returns first element in sequence that satisfies predicate otherwise returns the first element in the sequence. Returns null if no value found.

    Parameters

    • Optionalpredicate: (x: TSource) => boolean

      A function to test each element for a condition. Optional.

    Returns null | TSource

    The first element in the sequence or the first element that passes the test in the specified predicate function. Returns null if no value found.

  • Returns the first element of the sequence that satisfies a condition or a default value if no such element is found.

    Parameters

    • predicate: (x: TSource) => Promise<boolean>

      An async function to test each element for a condition.

    Returns Promise<null | TSource>

    null if source is empty or if no element passes the test specified by predicate; otherwise, the first element in source that passes the test specified by predicate.

  • Correlates the elements of two sequences based on equality of keys and groups the results.

    Type Parameters

    • TInner
    • TKey
    • TResult

    Parameters

    • inner: Iterable<TInner>

      The sequence to join to the first sequence.

    • outerKeySelector: (value: TSource) => TKey

      The sequence to join to the first sequence.

    • innerKeySelector: (value: TInner) => TKey

      A function to extract the join key from each element of the second sequence.

    • resultSelector: (element: TSource, collection: TInner[]) => TResult

      A function to create a result element from an element from the first sequence and a collection of matching elements from the second sequence.

    • Optionalcomparer: IEqualityComparer<TKey>

      To compare keys. Optional.

    Returns IEnumerable<TResult>

    An IEnumerable that contains elements of type TResult that are obtained by performing a grouped join on two sequences.

  • Correlates the elements of two sequences based on equality of keys and groups the results.

    Type Parameters

    • TInner
    • TKey
    • TResult

    Parameters

    • inner: Iterable<TInner>

      The sequence to join to the first sequence. Can be async.

    • outerKeySelector: (value: TSource) => TKey | Promise<TKey>

      The sequence to join to the first sequence. Can be async.

    • innerKeySelector: (value: TInner) => TKey | Promise<TKey>

      A function to extract the join key from each element of the second sequence.

    • resultSelector: (element: TSource, collection: TInner[]) => TResult | Promise<TResult>

      A function to create a result element from an element from the first sequence and a collection of matching elements from the second sequence. Can be async.

    • Optionalcomparer: IEqualityComparer<TKey>

      To compare keys. Optional.

    Returns IAsyncEnumerable<TResult>

    An IAsyncEnumerable that contains elements of type TResult that are obtained by performing a grouped join on two sequences.

  • Returns the last element of a sequence. If predicate is specified, the last element of a sequence that satisfies a specified condition.

    Parameters

    • Optionalpredicate: (x: TSource) => boolean

      A function to test each element for a condition. Optional.

    Returns TSource

    The value at the last position in the source sequence or the last element in the sequence that passes the test in the specified predicate function.

    The source sequence is empty.

  • Returns the last element of a sequence that satisfies a specified condition.

    Parameters

    • predicate: (x: TSource) => Promise<boolean>

      A function to test each element for a condition.

    Returns Promise<TSource>

    The last element in the sequence that passes the test in the specified predicate function.

    The source sequence is empty.

  • Returns the last element of a sequence. If predicate is specified, the last element of a sequence that satisfies a specified condition.

    Parameters

    • Optionalpredicate: (x: TSource) => boolean

      A function to test each element for a condition. Optional.

    Returns null | TSource

    The value at the last position in the source sequence or the last element in the sequence that passes the test in the specified predicate function.

  • Returns the last element of a sequence that satisfies a specified condition.

    Parameters

    • predicate: (x: TSource) => Promise<boolean>

      A function to test each element for a condition.

    Returns Promise<null | TSource>

    The last element in the sequence that passes the test in the specified predicate function. Null if no elements.

  • Returns the maximum value in a sequence of values.

    Parameters

    Returns number

    The maximum value in the sequence.

    source contains no elements.

  • Invokes a transform function on each element of a sequence and returns the maximum value.

    Parameters

    • selector: (x: TSource) => number

      A transform function to apply to each element.

    Returns number

    The maximum value in the sequence.

    source contains no elements.

  • Invokes an async transform function on each element of a sequence and returns the maximum value.

    Parameters

    • selector: (x: TSource) => Promise<number>

      A transform function to apply to each element.

    Returns Promise<number>

    The maximum value in the sequence.

    source contains no elements.

  • Returns the minimum value in a sequence of values.

    Parameters

    Returns number

    The minimum value in the sequence.

    source contains no elements.

  • Invokes a transform function on each element of a sequence and returns the minimum value.

    Parameters

    • selector: (x: TSource) => number

      A transform function to apply to each element.

    Returns number

    The minimum value in the sequence.

    source contains no elements.

  • Invokes a transform function on each element of a sequence and returns the minimum value.

    Parameters

    • selector: (x: TSource) => Promise<number>

      A transform function to apply to each element.

    Returns Promise<number>

    The minimum value in the sequence.

    source contains no elements.

  • Partitions the values into a tuple of failing and passing arrays

    Parameters

    • predicate: (x: TSource) => boolean

      Predicate to determine whether a value passes or fails

    Returns [pass: TSource[], fail: TSource[]]

    [values that pass, values that fail]

  • Partitions the values into a tuple of failing and passing arrays

    Parameters

    • predicate: (x: TSource) => Promise<boolean>

      Predicate to determine whether a value passes or fails

    Returns Promise<[pass: TSource[], fail: TSource[]]>

    [values that pass, values that fail]

  • Projects each element of a sequence to an IAsyncEnumerable and flattens the resulting sequences into one sequence.

    Type Parameters

    • TResult

    Parameters

    • selector: (x: TSource, index: number) => Promise<Iterable<TResult, any, any>>

      A transform function to apply to each element.

    Returns IAsyncEnumerable<TResult>

    An IAsyncEnumerable whose elements are the result of invoking the one-to-many transform function on each element of the input sequence.

  • Returns the only element of a sequence that satisfies a specified condition (if specified), and throws an exception if more than one such element exists.

    Parameters

    • Optionalpredicate: (x: TSource) => boolean

      A function to test an element for a condition. (Optional)

    Returns TSource

    The single element of the input sequence that satisfies a condition.

    No element satisfies the condition in predicate. OR More than one element satisfies the condition in predicate. OR The source sequence is empty.

  • Returns the only element of a sequence that satisfies a specified condition, and throws an exception if more than one such element exists.

    Parameters

    • predicate: (x: TSource) => Promise<boolean>

      A function to test an element for a condition.

    Returns Promise<TSource>

    The single element of the input sequence that satisfies a condition.

    No element satisfies the condition in predicate. OR More than one element satisfies the condition in predicate. OR The source sequence is empty.

  • If predicate is specified returns the only element of a sequence that satisfies a specified condition, ootherwise returns the only element of a sequence. Returns a default value if no such element exists.

    Parameters

    • Optionalpredicate: (x: TSource) => boolean

      A function to test an element for a condition. Optional.

    Returns null | TSource

    The single element of the input sequence that satisfies the condition, or null if no such element is found.

    If predicate is specified more than one element satisfies the condition in predicate, otherwise the input sequence contains more than one element.

  • Returns the only element of a sequence that satisfies a specified condition. Returns a default value if no such element exists.

    Parameters

    • predicate: (x: TSource) => Promise<boolean>

      A function to test an element for a condition. Optional.

    Returns Promise<null | TSource>

    The single element of the input sequence that satisfies the condition, or null if no such element is found.

    If predicate is specified more than one element satisfies the condition in predicate, otherwise the input sequence contains more than one element.

  • Bypasses a specified number of elements in a sequence and then returns the remaining elements.

    Parameters

    • count: number

      The number of elements to skip before returning the remaining elements.

    Returns IEnumerable<TSource>

    An IEnumerable that contains the elements that occur after the specified index in the input sequence.

  • Bypasses elements in a sequence as long as a specified condition is true and then returns the remaining elements. The element's index is used in the logic of the predicate function.

    Parameters

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

      A function to test each source element for a condition; the second parameter of the function represents the index of the source element.

    Returns IEnumerable<TSource>

    An IEnumerable that contains the elements from the input sequence starting at the first element in the linear series that does not pass the test specified by predicate.

  • Bypasses elements in a sequence as long as a specified condition is true and then returns the remaining elements. The element's index is used in the logic of the predicate function.

    Parameters

    • predicate: (x: TSource, index: number) => Promise<boolean>

      A function to test each source element for a condition; the second parameter of the function represents the index of the source element.

    Returns IAsyncEnumerable<TSource>

    An IAsyncEnumerable that contains the elements from the input sequence starting at the first element in the linear series that does not pass the test specified by predicate.

  • Computes the sum of the sequence of numeric values.

    Parameters

    Returns number

    The sum of the values in the sequence.

  • Computes the sum of the sequence of numeric values that are obtained by invoking a transform function on each element of the input sequence.

    Parameters

    • selector: (x: TSource) => number

      A transform function to apply to each element.

    Returns number

    The sum of the projected values.

  • Computes the sum of the sequence of numeric values that are obtained by invoking a transform function on each element of the input sequence.

    Parameters

    • selector: (x: TSource) => Promise<number>

      An async transform function to apply to each element.

    Returns Promise<number>

    The sum of the projected values.

  • Returns a specified number of contiguous elements from the start of a sequence.

    Parameters

    • amount: number

      The number of elements to return.

    Returns IEnumerable<TSource>

    An IEnumerable that contains the specified number of elements from the start of the input sequence.

  • Returns elements from a sequence as long as a specified condition is true. The element's index is used in the logic of the predicate function.

    Parameters

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

      A function to test each source element for a condition; the second parameter of the function represents the index of the source element.

    Returns IEnumerable<TSource>

    An IEnumerable that contains elements from the input sequence that occur before the element at which the test no longer passes.

  • Returns elements from a sequence as long as a specified condition is true. The element's index is used in the logic of the predicate function.

    Parameters

    • predicate: (x: TSource, index: number) => Promise<boolean>

      A async function to test each source element for a condition; the second parameter of the function represents the index of the source element.

    Returns IAsyncEnumerable<TSource>

    An IAsyncEnumerable that contains elements from the input sequence that occur before the element at which the test no longer passes.

  • Converts the Iteration to an Object. Duplicate values will be overriden.

    Type Parameters

    • TKey extends string | number | symbol

    Parameters

    • selector: (x: TSource) => TKey

      A function to determine the Key based on the value.

    Returns Record<TKey, TSource>

    KVP Object

  • Converts the Iteration to an Object. Duplicate values will be overriden.

    Type Parameters

    • TKey extends string | number | symbol

    Parameters

    • selector: (x: TSource) => Promise<TKey>

      An async function to determine the Key based on the value.

    Returns Promise<Record<TKey, TSource>>

    KVP Object

  • Filters a sequence of values based on a predicate. Each element's index is used in the logic of the predicate function.

    Parameters

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

      A function to test each source element for a condition; the second parameter of the function represents the index of the source element.

    Returns IEnumerable<TSource>

    An IEnumerable that contains elements from the input sequence that satisfy the condition.

  • Filters a sequence of values based on a predicate. Each element's index is used in the logic of the predicate function.

    Parameters

    • predicate: (x: TSource, index: number) => Promise<boolean>

      A async function to test each source element for a condition; the second parameter of the function represents the index of the source element.

    Returns IAsyncEnumerable<TSource>

    An IAsyncEnumerable that contains elements from the input sequence that satisfy the condition.