Langium - v4.0.0
    Preparing search index...

    Class StreamImpl<S, T>

    The default implementation of Stream works with two input functions:

    • The first function creates the initial state of an iteration.
    • The second function gets the current state as argument and returns an IteratorResult.

    Type Parameters

    • S
    • T

    Hierarchy (View Summary)

    Implements

    Index

    Constructors

    Properties

    nextFn: (state: S) => IteratorResult<T>
    startFn: () => S

    Methods

    • Returns a stream containing only the distinct elements from this stream. Equality is determined with the same rules as a standard Set.

      Type Parameters

      • Key = T

      Parameters

      • Optionalby: (element: T) => Key

        A function returning the key used to check equality with a previous stream element. If omitted, the stream elements themselves are used for comparison.

      Returns Stream<T>

    • Returns a stream that contains all elements that don't exist in the other iterable. Equality is determined with the same rules as a standard Set.

      Type Parameters

      • Key = T

      Parameters

      • other: Iterable<T>

        The elements that should be exluded from this stream.

      • Optionalkey: (element: T) => Key

        A function returning the key used to check quality. If omitted, the stream elements themselves are used for comparison.

      Returns Stream<T>

    • Returns the value of the first element in the stream that meets the condition, or undefined if there is no such element.

      Type Parameters

      • S

      Parameters

      • predicate: (value: T) => value is S

        This method calls predicate once for each element of the stream, in ascending order, until it finds one where predicate returns a value which is coercible to the Boolean value true.

      Returns undefined | S

    • Parameters

      • predicate: (value: T) => unknown

      Returns undefined | T

    • Returns the index of the first element in the stream that meets the condition, or -1 if there is no such element.

      Parameters

      • predicate: (value: T) => unknown

        This method calls predicate once for each element of the stream, in ascending order, until it finds one where predicate returns a value which is coercible to the Boolean value true.

      Returns number

    • Returns a new stream with all sub-stream or sub-array elements concatenated into it recursively up to the specified depth.

      Type Parameters

      • D extends number = 1

      Parameters

      • Optionaldepth: D

        The maximum recursion depth. Defaults to 1.

      Returns FlatStream<T, D>

    • Calls a defined callback function on each element of the stream and then flattens the result into a new stream. This is identical to a map followed by flat with depth 1.

      Type Parameters

      • U

      Parameters

      • callbackfn: (value: T) => U | Iterable<U, any, any>

        Lazily evaluated function mapping stream elements.

      Returns Stream<U>

    • Performs the specified action for each element in the stream.

      Parameters

      • callbackfn: (value: T, index: number) => void

        Function called once for each element in the stream.

      Returns void

    • Determines whether the stream includes a certain element, returning true or false as appropriate.

      Parameters

      • searchElement: T

        The element to search for.

      Returns boolean

    • Returns the index of the first occurrence of a value in the stream, or -1 if it is not present.

      Parameters

      • searchElement: T

        The value to locate in the array.

      • fromIndex: number = 0

        The stream index at which to begin the search. If fromIndex is omitted, the search starts at index 0.

      Returns number

    • Adds all elements of the stream into a string, separated by the specified separator string.

      Parameters

      • separator: string = ','

        A string used to separate one element of the stream from the next in the resulting string. If omitted, the steam elements are separated with a comma.

      Returns string

    • Returns a stream that yields the results of calling the specified callback function on each element of the stream. The function is called when the resulting stream elements are actually accessed, so accessing the resulting stream multiple times means the function is also called multiple times for each element of the stream.

      Type Parameters

      • U

      Parameters

      • callbackfn: (value: T) => U

        Lazily evaluated function mapping stream elements.

      Returns Stream<U>

    • Type Parameters

      • U

      Parameters

      • iterator: Iterator<T>
      • callbackfn: (previousValue: T | U, currentValue: T) => U
      • OptionalinitialValue: U

      Returns undefined | T | U

    • Calls the specified callback function for all elements in the stream. The return value of the callback function is the accumulated result, and is provided as an argument in the next call to the callback function.

      Parameters

      • callbackfn: (previousValue: T, currentValue: T) => T

        This method calls the function once for each element in the stream, providing the previous and current values of the reduction.

      Returns undefined | T

    • Type Parameters

      • U = T

      Parameters

      • callbackfn: (previousValue: U, currentValue: T) => U
      • initialValue: U

      Returns U

    • Calls the specified callback function for all elements in the stream, in descending order. The return value of the callback function is the accumulated result, and is provided as an argument in the next call to the callback function.

      Parameters

      • callbackfn: (previousValue: T, currentValue: T) => T

        This method calls the function once for each element in the stream, providing the previous and current values of the reduction.

      Returns undefined | T

    • Type Parameters

      • U = T

      Parameters

      • callbackfn: (previousValue: U, currentValue: T) => U
      • initialValue: U

      Returns U

    • Determines whether any member of the stream satisfies the specified test.

      Parameters

      • predicate: (value: T) => unknown

        This method calls the predicate function for each element in the stream until the predicate returns a value which is coercible to the Boolean value true, or until the end of the stream.

      Returns boolean

    • Returns a stream that skips the first skipCount elements from this stream.

      Parameters

      • skipCount: number = 1

        The number of elements to skip. If this is larger than the number of elements in the stream, an empty stream is returned. Defaults to 1.

      Returns Stream<T>

    • Collects all elements of this stream into a Map, applying the provided functions to determine keys and values.

      Type Parameters

      • K = T
      • V = T

      Parameters

      • OptionalkeyFn: (e: T) => K

        The function to derive map keys. If omitted, the stream elements are used as keys.

      • OptionalvalueFn: (e: T) => V

        The function to derive map values. If omitted, the stream elements are used as values.

      Returns Map<K, V>