Class Lz<T>

Type Parameters

  • T

Hierarchy

Implements

  • IterableIterator<T>

Constructors

  • Type Parameters

    • T

    Parameters

    • iterable: IterableIterator<T>

    Returns Lz<T>

Properties

identityFunction: IdentityFunction<any> = ...

Methods

  • Returns IterableIterator<T>

  • Applies an accumulator function over a sequence. The specified seed value is used as the initial accumulator value.

    Type Parameters

    • U

    Parameters

    • func: AccumulatorFunction<T, U>

      An accumulator function to be invoked on each element.

    • Optional seed: U

      The initial accumulator value.

    Returns U

    The final accumulator value.

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

    Parameters

    • predicate: PredicateFunction<T>

      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 any element of a sequence satisfies a condition.

    Parameters

    • predicate: PredicateFunction<T>

      A function to test each element for a condition.

    Returns boolean

    true if any elements in the source sequence pass the test in the specified predicate; otherwise, false.

  • Appends a value to the end of the sequence.

    Parameters

    • Rest ...elements: T[]

      The value(s) to append to source.

    Returns Lz<T>

    A new sequence that ends with element.

    Remarks

    This method is implemented by using deferred execution. The immediate return value is an object that stores all the information that is required to perform the action. The query represented by this method is not executed until the object is enumerated either by calling its toArray method directly or by using for...of.

  • 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: SelectorFunction<T, number>

      A transform function to apply to each element.

    Returns number

    The average of the sequence of values, or 0 if the source sequence is empty.

  • Parameters

    • Optional selector: SelectorFunction<number, number>

    Returns number

  • Concatenates two sequences.

    Parameters

    • second: LzIterable<T>

      The sequence to concatenate to the first sequence.

    Returns Lz<T>

    A sequence that contains the concatenated elements of the two input sequences.

  • Returns a number that represents how many elements in the specified sequence satisfy a condition.

    Parameters

    • Optional predicate: PredicateFunction<T>

      A function to test each element for a condition.

    Returns number

    A number that represents how many elements in the sequence satisfy the condition in the predicate function.

  • Returns the elements of the specified sequence or the specified value as a singleton collection if the sequence is empty.

    Parameters

    • defaultValue: T

      The value to return if the sequence is empty.

    Returns Lz<T>

    A sequence that contains defaultValue if source is empty; otherwise, source

    Remarks

    This method is implemented by using deferred execution. The immediate return value is an object that stores all the information that is required to perform the action. The query represented by this method is not executed until the object is enumerated either by calling its toArray method directly or by using for...of.

  • Produces the symmetrical set difference of two sequences by using the specified ComparatorFunction to compare values.

    Parameters

    • second: LzIterable<T>

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

    • Optional comparator: ComparatorFunction<T>

      Optional. A ComparatorFunction to compare values.

    Returns Lz<T>

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

    Remarks

    This method is implemented by using deferred execution. The immediate return value is an object that stores all the information that is required to perform the action. The query represented by this method is not executed until the object is enumerated either by calling its toArray method directly or by using for...of.

  • Returns distinct elements from a sequence by using a specified ComparatorFunction to compare values.

    Parameters

    • Optional comparator: ComparatorFunction<T>

      Optional. A ComparatorFunction to compare values.

    Returns Lz<T>

    A sequence that contains distinct elements from the source sequence.

    Remarks

    This method is implemented by using deferred execution. The immediate return value is an object that stores all the information that is required to perform the action. The query represented by this method is not executed until the object is enumerated either by calling its toArray method directly or by using for...of.

  • Produces the set difference of two sequences by using the specified ComparatorFunction to compare values.

    Parameters

    • second: LzIterable<T>

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

    • Optional comparator: ComparatorFunction<T>

      Optional. A ComparatorFunction to compare values.

    Returns Lz<T>

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

    Remarks

    This method is implemented by using deferred execution. The immediate return value is an object that stores all the information that is required to perform the action. The query represented by this method is not executed until the object is enumerated either by calling its toArray method directly or by using for...of.

  • Returns the first element of a sequence.

    Parameters

    • Optional predicate: PredicateFunction<T>

      A function to test each element for a condition.

    Returns T

    The first element.

    Throws

    If the source sequence contains no elements or the predicate did not match any elements.

  • Returns the first element of a sequence, or a default value if the sequence contains no elements.

    Parameters

    • defaultValue: T

      The default value.

    • Optional predicate: PredicateFunction<T>

      A function to test each element for a condition.

    Returns T

    The first element, or a default value if the sequence contains no elements.

  • Performs the specified action on each element of the sequence.

    Parameters

    • action: Action<T>

      The action delegate to perform on each element of the sequence.

    Returns void

  • Groups the elements of a sequence according to a specified key selector function and projects the elements for each group by using a specified function.

    Type Parameters

    • K

    Parameters

    • keySelector: SelectorFunction<T, K>

      A function to extract the key for each element.

    Returns LzGrouped<K, T[]>

    A Map where each entry contains a collection of objects of type T.

  • Groups the elements of a sequence according to a specified key selector function and projects the elements for each group by using a specified function.

    Type Parameters

    • K

    • V

    Parameters

    • keySelector: SelectorFunction<T, K>

      A function to extract the key for each element.

    • Optional elementSelector: SelectorFunction<T, V>

      A function to map each source element to an element in the returned Map.

    Returns LzGrouped<K, V[]>

    A Map where each entry contains a collection of objects of type V.

  • Inserts a value into the source sequence at the specified index.

    Parameters

    • element: T

      The value to insert to source.

    • index: number

      The index at which to insert element.

    Returns Lz<T>

    A new sequence that contains element at index.

    Remarks

    This method is implemented by using deferred execution. The immediate return value is an object that stores all the information that is required to perform the action. The query represented by this method is not executed until the object is enumerated either by calling its toArray method directly or by using for...of.

  • Produces the set intersection of two sequences.

    Parameters

    • second: LzIterable<T>

      A sequence whose distinct elements that also appear in the first sequence will be returned.

    • Optional comparator: ComparatorFunction<T>

      A ComparatorFunction to compare values.

    Returns Lz<T>

    A sequence that contains the elements that form the set intersection of two sequences.

    Remarks

    This method is implemented by using deferred execution. The immediate return value is an object that stores all the information that is required to perform the action. The query represented by this method is not executed until the object is enumerated either by calling its toArray method directly or by using for...of.

  • Correlates the elements of two sequences based on matching keys.

    Type Parameters

    • T2

    • K

    • U

    Parameters

    • inner: IterableIterator<T2> | T2[]

      The sequence to join to the first sequence.

    • outerKeySelector: SelectorFunction<T, K>

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

    • innerKeySelector: SelectorFunction<T2, K>

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

    • resultSelector: ((a, b) => U)

      A function to create a result element from two matching elements.

        • (a, b): U
        • Parameters

          • a: T
          • b: T2

          Returns U

    Returns Lz<U>

    A sequence that has elements of type U that are obtained by performing an inner join on two sequences.

    Remarks

    This method is implemented by using deferred execution. The immediate return value is an object that stores all the information that is required to perform the action. The query represented by this method is not executed until the object is enumerated either by calling its toArray method directly or by using for...of.

  • Returns the last element of a sequence.

    Parameters

    • Optional predicate: PredicateFunction<T>

      A function to test each element for a condition.

    Returns T

    The value at the last position in the source sequence.

    Throws

    If the source sequence contains no elements or the predicate did not match any elements.

  • Returns the last element of a sequence, or a default value if no element is found.

    Parameters

    • defaultValue: T

      The default value.

    • Optional predicate: PredicateFunction<T>

      A function to test each element for a condition.

    Returns T

    The value at the last position in the source sequence.

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

    Parameters

    • selector: SelectorFunction<T, number>

      A transform function to apply to each element.

    Returns number

    The maximum value in the sequence.

  • Parameters

    • Optional selector: SelectorFunction<number, number>

    Returns number

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

    Parameters

    • selector: SelectorFunction<T, number>

      A transform function to apply to each element.

    Returns number

    The minimum value in the sequence.

  • Parameters

    • Optional selector: SelectorFunction<number, number>

    Returns number

  • Parameters

    • Optional value: any

    Returns IteratorResult<T, any>

  • Sorts the elements of a sequence in ascending order according to a key.

    Type Parameters

    • V

    Parameters

    • selector: SelectorFunctionNoIndex<T, V>

      A function to extract a key from an element.

    Returns LzOrdered<T, V>

    A sequence whose elements are sorted according to a key.

  • Sorts the elements of a sequence in ascending or descending order according to a key.

    Type Parameters

    • V

    Parameters

    • selector: SelectorFunctionNoIndex<T, V>

      A function to extract a key from an element.

    • descending: boolean

      Whether to sort in descending order rather than ascending.

    Returns LzOrdered<T, V>

    A sequence whose elements are sorted according to a key.

  • Sorts the elements of a sequence in ascending order by using a specified comparator.

    Type Parameters

    • V

    Parameters

    • selector: SelectorFunctionNoIndex<T, V>

      A function to extract a key from an element.

    • comparator: ComparatorFunction<V>

      A ComparatorFunction to compare keys.

    Returns LzOrdered<T, V>

    A sequence whose elements are sorted according to a key.

  • Sorts the elements of a sequence in ascending or descending order by using a specified comparator.

    Type Parameters

    • V

    Parameters

    • selector: SelectorFunctionNoIndex<T, V>

      A function to extract a key from an element.

    • comparator: ComparatorFunction<V>

      A ComparatorFunction to compare keys.

    • descending: boolean

      Whether to sort in descending order rather than ascending.

    Returns LzOrdered<T, V>

    A sequence whose elements are sorted according to a key.

  • Sorts the elements of a sequence in descending order according to a key.

    Type Parameters

    • V

    Parameters

    • selector: SelectorFunctionNoIndex<T, V>

      A function to extract a key from an element.

    Returns LzOrdered<T, V>

    A sequence whose elements are sorted according to a key.

  • Sorts the elements of a sequence in descending order by using a specified comparator.

    Type Parameters

    • V

    Parameters

    • selector: SelectorFunctionNoIndex<T, V>

      A function to extract a key from an element.

    • comparator: ComparatorFunction<V>

      A ComparatorFunction to compare keys.

    Returns LzOrdered<T, V>

    A sequence whose elements are sorted according to a key.

  • Partitions the sequence into arrays of specified size.

    Parameters

    • size: number

      The size of each partitioned array. The last array may be smaller if there are not enough elements in the sequence to fill it.

    Returns Lz<T[]>

    A sequence that contains the partitioned arrays.

  • Adds a value to the beginning of the sequence.

    Parameters

    • Rest ...elements: T[]

      The value(s) to prepend to source.

    Returns Lz<T>

    A new sequence that begins with element.

    Remarks

    This method is implemented by using deferred execution. The immediate return value is an object that stores all the information that is required to perform the action. The query represented by this method is not executed until the object is enumerated either by calling its toArray method directly or by using for...of.

  • Parameters

    • Optional value: any

    Returns IteratorResult<T, any>

  • Inverts the order of the elements in a sequence.

    Returns Lz<T>

    A sequence whose elements correspond to those of the input sequence in reverse order.

  • Projects each element of a sequence into a new form.

    Type Parameters

    • U

    Parameters

    • selector: SelectorFunction<T, U>

      A transform function to apply to each element.

    Returns Lz<U>

    An iterable whose elements are the result of invoking the transform function on each element of source.

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

    Type Parameters

    • U

    Parameters

    • selector: SelectorFunction<T, IterableIterator<U> | U[]>

      A transform function to apply to each element.

    Returns Lz<U>

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

  • Determines whether two sequences are equal by comparing their elements by using a specified ComparatorFunction.

    Parameters

    • second: LzIterable<T>

      A sequence to compare to the first sequence.

    • Optional comparator: ComparatorFunction<T>

      A ComparatorFunction to use to compare elements.

    Returns boolean

    true if the two source sequences are of equal length and their corresponding elements compare equal according to comparator; otherwise, false.

  • Returns the only element of a sequence, and throws an exception if there is not exactly one element in the sequence.

    Parameters

    • Optional predicate: PredicateFunction<T>

      A function to test an element for a condition. Return true to keep the element, false otherwise.

    Returns T

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

    Throws

    If 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 or a default value if no such element exists; this method throws an exception if more than one element satisfies the condition.

    Parameters

    • defaultValue: T

      The default value.

    • Optional predicate: PredicateFunction<T>

      A function to test an element for a condition. Return true to keep the element, false otherwise.

    Returns T

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

    Throws

    If more than one element satisfies the condition in predicate.

  • 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 Lz<T>

    An iterable 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.

    Parameters

    • predicate: PredicateFunction<T>

      A function to test each element for a condition.

    Returns Lz<T>

    A sequence 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 values that are obtained by invoking a transform function on each element of the input sequence.

    Parameters

    • selector: SelectorFunction<T, number>

      A transform function to apply to each element.

    Returns number

    The sum of the projected values.

  • Parameters

    • Optional selector: SelectorFunction<number, number>

    Returns number

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

    Parameters

    • count: number

      The number of elements to return.

    Returns Lz<T>

    An iterable 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.

    Parameters

    • predicate: PredicateFunction<T>

      A function to test each element for a condition.

    Returns Lz<T>

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

  • Parameters

    • Optional e: any

    Returns IteratorResult<T, any>

  • Creates an array from a IterableIterator.

    Returns T[]

    An array that contains the elements from the input sequence.

  • Creates a Map from a sequence of IterableIterator<[T1, T2]>

    Type Parameters

    • T1

    • T2

    Returns Map<T1, T2>

    A Map that contains keys and values.

  • Creates a Map from an Array according to a specified key selector function.

    Type Parameters

    • K

    • T

    Parameters

    • keySelector: SelectorFunction<T, K>

      A function to extract a key from each element.

    Returns Map<K, T>

    A Map that contains keys and values.

  • Creates a Map from an Array according to a specified key selector function.

    Type Parameters

    • K

    • U

    Parameters

    • keySelector: SelectorFunction<T, K>

      A function to extract a key from each element.

    • elementSelector: SelectorFunction<T, U>

      A function to map each source element to an element in the returned Map.

    Returns Map<K, U>

    A Map that contains keys and values.

  • Returns the input typed as LzIterable.

    Returns Lz<T>

    The input sequence typed as LzIterable.

  • Creates a Set from an IterableIterator.

    Returns Set<T>

    A Set that contains values of type T selected from the input sequence.

  • Produces the set union of two sequences.

    Parameters

    • second: LzIterable<T>

      A sequence whose distinct elements form the second set for the union.

    • Optional comparator: ComparatorFunction<T>

      The ComparatorFunction to compare values.

    Returns Lz<T>

    A sequence that contains the elements from both input sequences, excluding duplicates.

    Remarks

    This method is implemented by using deferred execution. The immediate return value is an object that stores all the information that is required to perform the action. The query represented by this method is not executed until the object is enumerated either by calling its toArray method directly or by using for...of.

  • Filters a sequence of values based on a predicate.

    Parameters

    • predicate: PredicateFunction<T>

      A function to test each element for a condition. Return true to keep the element, false otherwise.

    Returns Lz<T>

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

  • Applies a specified function to the corresponding elements of two sequences, producing a sequence of the results.

    Type Parameters

    • U

    • V

    Parameters

    • second: LzIterable<U>

      The second sequence to merge.

    • resultSelector: ((first, second) => V)

      A function that specifies how to merge the elements from the two sequences.

        • (first, second): V
        • Parameters

          • first: T
          • second: U

          Returns V

    Returns Lz<V>

    A sequence that contains merged elements of two input sequences.

  • Applies an accumulator function over a sequence. The specified seed value is used as the initial accumulator value.

    Type Parameters

    • T

    • U

    Parameters

    • source: LzIterable<T>

      The sequence to aggregate over.

    • func: AccumulatorFunction<T, U>

      An accumulator function to be invoked on each element.

    • Optional seed: U

      The initial accumulator value.

    Returns U

    The final accumulator value.

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

    Type Parameters

    • T

    Parameters

    • source: LzIterable<T>

      The sequence that contains the elements to apply the predicate to.

    • predicate: PredicateFunction<T>

      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 any element of a sequence satisfies a condition.

    Type Parameters

    • T

    Parameters

    • source: LzIterable<T>

      The sequence whose elements to apply the predicate to.

    • predicate: PredicateFunction<T>

      A function to test each element for a condition.

    Returns boolean

    true if any elements in the source sequence pass the test in the specified predicate; otherwise, false.

  • Appends a value to the end of the sequence.

    Type Parameters

    • T

    Parameters

    • source: LzIterable<T>

      A sequence of values.

    • Rest ...elements: T[]

      The value(s) to append to source.

    Returns Lz<T>

    A new sequence that ends with element.

    Remarks

    This method is implemented by using deferred execution. The immediate return value is an object that stores all the information that is required to perform the action. The query represented by this method is not executed until the object is enumerated either by calling its toArray method directly or by using for...of.

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

    Type Parameters

    • T

    Parameters

    • source: LzIterable<T>

      A sequence of values that are used to calculate an average.

    • selector: SelectorFunction<T, number>

      A transform function to apply to each element.

    Returns number

    The average of the sequence of values, or 0 if the source sequence is empty.

  • Type Parameters

    • T extends number

    Parameters

    • source: LzIterable<T>
    • Optional selector: SelectorFunction<T, number>

    Returns number

  • Concatenates two sequences.

    Type Parameters

    • T

    Parameters

    • first: LzIterable<T>

      The first sequence to concatenate.

    • second: LzIterable<T>

      The sequence to concatenate to the first sequence.

    Returns Lz<T>

    A sequence that contains the concatenated elements of the two input sequences.

  • Returns a number that represents how many elements in the specified sequence satisfy a condition.

    Type Parameters

    • T

    Parameters

    • source: LzIterable<T>

      The sequence to return elements from.

    • Optional predicate: PredicateFunction<T>

      A function to test each element for a condition.

    Returns number

    A number that represents how many elements in the sequence satisfy the condition in the predicate function.

  • Returns the elements of the specified sequence or the specified value as a singleton collection if the sequence is empty.

    Type Parameters

    • T

    Parameters

    • source: LzIterable<T>

      The sequence to return the specified value for if it is empty.

    • defaultValue: T

      The value to return if the sequence is empty.

    Returns Lz<T>

    A sequence that contains defaultValue if source is empty; otherwise, source.

    Remarks

    This method is implemented by using deferred execution. The immediate return value is an object that stores all the information that is required to perform the action. The query represented by this method is not executed until the object is enumerated either by calling its toArray method directly or by using for...of.

  • Produces the symmetrical set difference of two sequences by using the specified ComparatorFunction to compare values.

    Type Parameters

    • T

    Parameters

    • first: LzIterable<T>

      A sequence whose elements that also occur in the second sequence will cause those elements to be removed from the returned sequence.

    • second: LzIterable<T>

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

    • Optional comparator: ComparatorFunction<T>

      Optional. A ComparatorFunction to compare values.

    Returns Lz<T>

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

    Remarks

    This method is implemented by using deferred execution. The immediate return value is an object that stores all the information that is required to perform the action. The query represented by this method is not executed until the object is enumerated either by calling its toArray method directly or by using for...of.

  • Returns distinct elements from a sequence by using a specified ComparatorFunction to compare values.

    Type Parameters

    • T

    Parameters

    • source: LzIterable<T>

      The sequence to remove duplicate elements from.

    • Optional comparator: ComparatorFunction<T>

      Optional. A ComparatorFunction to compare values.

    Returns Lz<T>

    A sequence that contains distinct elements from the source sequence.

    Remarks

    This method is implemented by using deferred execution. The immediate return value is an object that stores all the information that is required to perform the action. The query represented by this method is not executed until the object is enumerated either by calling its toArray method directly or by using for...of.

  • Returns an empty sequence that has the specified type argument.

    Type Parameters

    • T

    Returns Lz<T>

    An empty sequence whose type argument is T.

  • Produces the set difference of two sequences by using the specified ComparatorFunction to compare values.

    Type Parameters

    • T

    Parameters

    • first: LzIterable<T>

      A sequence whose elements that are not also in second will be returned.

    • second: LzIterable<T>

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

    • Optional comparator: ComparatorFunction<T>

      Optional. A ComparatorFunction to compare values.

    Returns Lz<T>

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

    Remarks

    This method is implemented by using deferred execution. The immediate return value is an object that stores all the information that is required to perform the action. The query represented by this method is not executed until the object is enumerated either by calling its toArray method directly or by using for...of.

  • Returns the first element of a sequence.

    Type Parameters

    • T

    Parameters

    • source: LzIterable<T>

      The sequence to return an element from.

    • Optional predicate: PredicateFunction<T>

      A function to test each element for a condition.

    Returns T

    The first element.

    Throws

    If the source sequence contains no elements or the predicate did not match any elements.

  • Returns the first element of a sequence, or a default value if the sequence contains no elements.

    Type Parameters

    • T

    Parameters

    • source: LzIterable<T>

      The sequence to return an element from.

    • defaultValue: T

      The default value.

    • Optional predicate: PredicateFunction<T>

      A function to test each element for a condition.

    Returns T

    The first element, or a default value if the sequence contains no elements.

  • Type Parameters

    • T

    Parameters

    • source: LzIterable<T>
    • action: Action<T>

    Returns void

  • Groups the elements of a sequence according to a specified key selector function and projects the elements for each group by using a specified function.

    Type Parameters

    • T

    • K

    Parameters

    • source: LzIterable<T>

      The sequence whose elements to group.

    • keySelector: SelectorFunction<T, K>

      A function to extract the key for each element.

    Returns LzGrouped<K, T[]>

    A Map where each entry contains a collection of objects of type V.

  • Groups the elements of a sequence according to a specified key selector function and projects the elements for each group by using a specified function.

    Type Parameters

    • T

    • K

    • V

    Parameters

    • source: LzIterable<T>

      The sequence whose elements to group.

    • keySelector: SelectorFunction<T, K>

      A function to extract the key for each element.

    • Optional elementSelector: SelectorFunction<T, V>

      A function to map each source element to an element in the returned Map.

    Returns LzGrouped<K, V[]>

    A Map where each entry contains a collection of objects of type V.

  • Inserts a value into the source sequence at the specified index.

    Type Parameters

    • T

    Parameters

    • source: LzIterable<T>

      The sequence in which to insert the new item.

    • element: T

      The value to insert to source.

    • index: number

      The index at which to insert element.

    Returns Lz<T>

    A new sequence that contains element at index.

    Remarks

    This method is implemented by using deferred execution. The immediate return value is an object that stores all the information that is required to perform the action. The query represented by this method is not executed until the object is enumerated either by calling its toArray method directly or by using for...of.

  • Produces the set intersection of two sequences.

    Type Parameters

    • T

    Parameters

    • first: LzIterable<T>

      A sequence whose distinct elements that also appear in second will be returned.

    • second: LzIterable<T>

      A sequence whose distinct elements that also appear in the first sequence will be returned.

    • Optional comparator: ComparatorFunction<T>

      A ComparatorFunction to compare values.

    Returns Lz<T>

    A sequence that contains the elements that form the set intersection of two sequences.

    Remarks

    This method is implemented by using deferred execution. The immediate return value is an object that stores all the information that is required to perform the action. The query represented by this method is not executed until the object is enumerated either by calling its toArray method directly or by using for...of.

  • Correlates the elements of two sequences based on matching keys.

    Type Parameters

    • T1

    • T2

    • K

    • U

    Parameters

    • outer: IterableIterator<T1> | T1[]

      The first sequence to join.

    • inner: IterableIterator<T2> | T2[]

      The sequence to join to the first sequence.

    • outerKeySelector: SelectorFunction<T1, K>

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

    • innerKeySelector: SelectorFunction<T2, K>

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

    • resultSelector: ((a, b) => U)

      A function to create a result element from two matching elements.

        • (a, b): U
        • Parameters

          • a: T1
          • b: T2

          Returns U

    Returns Lz<U>

    A sequence that has elements of type U that are obtained by performing an inner join on two sequences.

    Remarks

    This method is implemented by using deferred execution. The immediate return value is an object that stores all the information that is required to perform the action. The query represented by this method is not executed until the object is enumerated either by calling its toArray method directly or by using for...of.

  • Returns the last element of a sequence.

    Type Parameters

    • T

    Parameters

    • source: LzIterable<T>

      A sequence to return the last element of.

    • Optional predicate: PredicateFunction<T>

      A function to test each element for a condition.

    Returns T

    The value at the last position in the source sequence.

    Throws

    If the source sequence contains no elements or the predicate did not match any elements.

  • Returns the last element of a sequence, or a default value if no element is found.

    Type Parameters

    • T

    Parameters

    • source: LzIterable<T>

      A sequence to return the last element of.

    • defaultValue: T

      The default value.

    • Optional predicate: PredicateFunction<T>

      A function to test each element for a condition.

    Returns T

    The value at the last position in the source sequence.

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

    Type Parameters

    • T

    Parameters

    • source: LzIterable<T>

      A sequence of values to determine the maximum value of.

    • selector: SelectorFunction<T, number>

      A transform function to apply to each element.

    Returns number

    The maximum value in the sequence.

  • Type Parameters

    • T extends number

    Parameters

    • source: LzIterable<T>
    • Optional selector: SelectorFunction<T, number>

    Returns number

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

    Type Parameters

    • T

    Parameters

    • source: LzIterable<T>

      A sequence of values to determine the minimum value of.

    • selector: SelectorFunction<T, number>

      A transform function to apply to each element.

    Returns number

    The minimum value in the sequence.

  • Type Parameters

    • T extends number

    Parameters

    • source: LzIterable<T>
    • Optional selector: SelectorFunction<T, number>

    Returns number

  • Sorts the elements of a sequence in ascending order according to a key.

    Type Parameters

    • T

    • V

    Parameters

    • source: LzIterable<T>

      A sequence of values to order.

    • selector: SelectorFunctionNoIndex<T, V>

      A function to extract a key from an element.

    Returns LzOrdered<T, V>

    A sequence whose elements are sorted according to a key.

  • Sorts the elements of a sequence in ascending or descending order according to a key.

    Type Parameters

    • T

    • V

    Parameters

    • source: LzIterable<T>

      A sequence of values to order.

    • selector: SelectorFunctionNoIndex<T, V>

      A function to extract a key from an element.

    • descending: boolean

      Whether to sort in descending order rather than ascending.

    Returns LzOrdered<T, V>

    A sequence whose elements are sorted according to a key.

  • Sorts the elements of a sequence in ascending order by using a specified comparator.

    Type Parameters

    • T

    • V

    Parameters

    • source: LzIterable<T>

      A sequence of values to order.

    • selector: SelectorFunctionNoIndex<T, V>

      A function to extract a key from an element.

    • comparator: ComparatorFunction<V>

      A ComparatorFunction to compare keys.

    Returns LzOrdered<T, V>

    A sequence whose elements are sorted according to a key.

  • Sorts the elements of a sequence in ascending or descending order by using a specified comparator.

    Type Parameters

    • T

    • V

    Parameters

    • source: LzIterable<T>

      A sequence of values to order.

    • selector: SelectorFunctionNoIndex<T, V>

      A function to extract a key from an element.

    • comparator: ComparatorFunction<V>

      A ComparatorFunction to compare keys.

    • descending: boolean

      Whether to sort in descending order rather than ascending.

    Returns LzOrdered<T, V>

    A sequence whose elements are sorted according to a key.

  • Sorts the elements of a sequence in descending order according to a key.

    Type Parameters

    • T

    • V

    Parameters

    • source: LzIterable<T>

      A sequence of values to order.

    • selector: SelectorFunctionNoIndex<T, V>

      A function to extract a key from an element.

    Returns LzOrdered<T, V>

    A sequence whose elements are sorted according to a key.

  • Sorts the elements of a sequence in descending order by using a specified comparator.

    Type Parameters

    • T

    • V

    Parameters

    • source: LzIterable<T>

      A sequence of values to order.

    • selector: SelectorFunctionNoIndex<T, V>

      A function to extract a key from an element.

    • comparator: ComparatorFunction<V>

      A ComparatorFunction to compare keys.

    Returns LzOrdered<T, V>

    A sequence whose elements are sorted according to a key.

  • Partitions the sequence into arrays of specified size.

    Type Parameters

    • T

    Parameters

    • source: LzIterable<T>

      The sequence whose elements to partition.

    • size: number

      The size of each partitioned array. The last array may be smaller if there are not enough elements in the sequence to fill it.

    Returns Lz<T[]>

    A sequence that contains the partitioned arrays.

  • Adds a value to the beginning of the sequence.

    Type Parameters

    • T

    Parameters

    • source: LzIterable<T>

      A sequence of values.

    • Rest ...elements: T[]

      The value(s) to prepend to source.

    Returns Lz<T>

    A new sequence that begins with element.

    Remarks

    This method is implemented by using deferred execution. The immediate return value is an object that stores all the information that is required to perform the action. The query represented by this method is not executed until the object is enumerated either by calling its toArray method directly or by using for...of.

  • Generates a sequence of integral numbers within a specified range.

    Parameters

    • start: number

      The value of the first integer in the sequence.

    • count: number

      The number of sequential integers to generate.

    Returns Lz<number>

    A sequence that contains a range of sequential integral numbers.

    Throws

    If count is less than 0.

    Remarks

    This method is implemented by using deferred execution. The immediate return value is an object that stores all the information that is required to perform the action. The query represented by this method is not executed until the object is enumerated either by calling its toArray method directly or by using for...of.

  • Generates a sequence that contains one repeated value.

    Type Parameters

    • T

    Parameters

    • element: T

      The value to be repeated.

    • count: number

      The number of times to repeat the value in the generated sequence.

    Returns Lz<T>

    A sequence that contains a repeated value.

    Throws

    If count is less than 0.

    Remarks

    This method is implemented by using deferred execution. The immediate return value is an object that stores all the information that is required to perform the action. The query represented by this method is not executed until the object is enumerated either by calling its toArray method directly or by using for...of.

  • Generates a sequence that contains the results of a repeated action.

    Type Parameters

    • T

    Parameters

    • selector: SelectorFunction<void, T>
    • count: number

      The number of times to repeat the action in the generated sequence.

    Returns Lz<T>

    A sequence that contains the results of the repeated action.

    Throws

    If count is less than 0.

    Remarks

    This method is implemented by using deferred execution. The immediate return value is an object that stores all the information that is required to perform the action. The query represented by this method is not executed until the object is enumerated either by calling its toArray method directly or by using for...of.

  • Inverts the order of the elements in a sequence.

    Type Parameters

    • T

    Parameters

    • source: LzIterable<T>

      A sequence of values to reverse.

    Returns Lz<T>

    A sequence whose elements correspond to those of the input sequence in reverse order.

  • Projects each element of a sequence into a new form.

    Type Parameters

    • T

    • U

    Parameters

    • source: LzIterable<T>

      An iterable of values to invoke a transform function on.

    • selector: SelectorFunction<T, U>

      A transform function to apply to each element.

    Returns Lz<U>

    An iterable whose elements are the result of invoking the transform function on each element of source.

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

    Type Parameters

    • T

    • U

    Parameters

    • source: LzIterable<T>

      A sequence of values to project.

    • selector: SelectorFunction<T, IterableIterator<U> | U[]>

      A transform function to apply to each element.

    Returns Lz<U>

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

  • Determines whether two sequences are equal by comparing their elements by using a specified ComparatorFunction.

    Type Parameters

    • T

    Parameters

    • first: LzIterable<T>

      A sequence to compare to second.

    • second: LzIterable<T>

      A sequence to compare to the first sequence.

    • comparator: ComparatorFunction<T> = Comparator.defaultComparator

      A ComparatorFunction to use to compare elements.

    Returns boolean

    true if the two source sequences are of equal length and their corresponding elements compare equal according to comparator; otherwise, false.

  • Returns the only element of a sequence, and throws an exception if there is not exactly one element in the sequence.

    Type Parameters

    • T

    Parameters

    • source: LzIterable<T>

      An iterable to return the single element of.

    • Optional predicate: PredicateFunction<T>

      A function to test an element for a condition. Return true to keep the element, false otherwise.

    Returns T

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

    Throws

    If 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 or a default value if no such element exists; this method throws an exception if more than one element satisfies the condition.

    Type Parameters

    • T

    Parameters

    • source: LzIterable<T>

      A sequence to return the single element from.

    • defaultValue: T

      The default value.

    • Optional predicate: PredicateFunction<T>

      A function to test an element for a condition. Return true to keep the element, false otherwise.

    Returns T

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

    Throws

    If more than one element satisfies the condition in predicate.

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

    Type Parameters

    • T

    Parameters

    • source: LzIterable<T>

      The sequence to return elements from.

    • count: number

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

    Returns Lz<T>

    An iterable 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.

    Type Parameters

    • T

    Parameters

    • source: LzIterable<T>

      A sequence to return elements from.

    • predicate: PredicateFunction<T>

      A function to test each element for a condition.

    Returns Lz<T>

    A sequence 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 values that are obtained by invoking a transform function on each element of the input sequence.

    Type Parameters

    • T

    Parameters

    • source: LzIterable<T>

      A sequence of values that are used to calculate a sum.

    • selector: SelectorFunction<T, number>

      A transform function to apply to each element.

    Returns number

    The sum of the projected values.

  • Type Parameters

    • T extends number

    Parameters

    • source: LzIterable<T>
    • Optional selector: SelectorFunction<T, number>

    Returns number

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

    Type Parameters

    • T

    Parameters

    • source: LzIterable<T>

      The sequence to return elements from.

    • count: number

      The number of elements to return.

    Returns Lz<T>

    An iterable 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.

    Type Parameters

    • T

    Parameters

    • source: LzIterable<T>

      A sequence to return elements from.

    • predicate: PredicateFunction<T>

      A function to test each element for a condition.

    Returns Lz<T>

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

  • Creates an array from a IterableIterator.

    Type Parameters

    • T

    Parameters

    • source: LzIterable<T>

      An IterableIterator to create an array from.

    Returns T[]

    An array that contains the elements from the input sequence.

  • Creates a Map from a sequence of IterableIterator<[T1, T2]>

    Type Parameters

    • T1

    • T2

    Parameters

    • source: LzIterable<[T1, T2]>

      The sequence to create a Map<K, T> from.

    Returns Map<T1, T2>

    A Map that contains keys and values.

  • Creates a Map from an Array according to a specified key selector function.

    Type Parameters

    • T

    • K

    Parameters

    • source: LzIterable<T>

      The sequence to create a Map<K, T> from.

    • keySelector: SelectorFunction<T, K>

      A function to extract a key from each element.

    Returns Map<K, T>

    A Map that contains keys and values.

  • Creates a Map from an Array according to a specified key selector function.

    Type Parameters

    • T

    • K

    • U

    Parameters

    • source: LzIterable<T>

      The sequence to create a Map<K, T> from.

    • keySelector: SelectorFunction<T, K>

      A function to extract a key from each element.

    • elementSelector: SelectorFunction<T, U>

      A function to map each source element to an element in the returned Map.

    Returns Map<K, U>

    A Map that contains keys and values.

  • Returns the input typed as LzIterable.

    Type Parameters

    • T

    Parameters

    • source: LzIterable<T>

      The sequence to type as LzIterable.

    Returns Lz<T>

    The input sequence typed as LzIterable.

  • Creates a Set from an IterableIterator.

    Type Parameters

    • T

    Parameters

    • source: LzIterable<T>

      An IterableIterator to create a Set from.

    Returns Set<T>

    A Set that contains values of type T selected from the input sequence.

  • Produces the set union of two sequences.

    Type Parameters

    • T

    Parameters

    • first: LzIterable<T>

      A sequence whose distinct elements form the first set for the union.

    • second: LzIterable<T>

      A sequence whose distinct elements form the second set for the union.

    • Optional comparator: ComparatorFunction<T>

      The ComparatorFunction to compare values.

    Returns Lz<T>

    A sequence that contains the elements from both input sequences, excluding duplicates.

    Remarks

    This method is implemented by using deferred execution. The immediate return value is an object that stores all the information that is required to perform the action. The query represented by this method is not executed until the object is enumerated either by calling its toArray method directly or by using for...of.

  • Filters a sequence of values based on a predicate.

    Type Parameters

    • T

    Parameters

    • source: LzIterable<T>

      An iterable to filter.

    • predicate: PredicateFunction<T>

      A function to test each element for a condition. Return true to keep the element, false otherwise.

    Returns Lz<T>

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

  • Applies a specified function to the corresponding elements of two sequences, producing a sequence of the results.

    Type Parameters

    • T

    • U

    • V

    Parameters

    • first: LzIterable<T>

      The first sequence to merge.

    • second: LzIterable<U>

      The second sequence to merge.

    • resultSelector: ((first, second) => V)

      A function that specifies how to merge the elements from the two sequences.

        • (first, second): V
        • Parameters

          • first: T
          • second: U

          Returns V

    Returns Lz<V>

    A sequence that contains merged elements of two input sequences.