Langium - v4.0.0
    Preparing search index...

    Class TreeStreamImpl<T>

    The default implementation of TreeStream takes a root element and a function that computes the children of its argument. Whether the root node included in the stream is controlled with the includeRoot option, which defaults to false.

    Type Parameters

    • T

    Hierarchy (View Summary)

    • StreamImpl<{ iterators: Iterator<T>[]; pruned: boolean }, T>
      • TreeStreamImpl

    Implements

    Index

    Constructors

    Properties

    nextFn: (
        state: { iterators: Iterator<T, any, any>[]; pruned: boolean },
    ) => IteratorResult<T>
    startFn: () => { iterators: Iterator<T, any, any>[]; pruned: boolean }

    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

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

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

    • 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

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