Langium - v4.0.0
    Preparing search index...

    Interface TreeStream<T>

    A tree stream is used to stream the elements of a tree, for example an AST or CST.

    interface TreeStream<T> {
        "[iterator]"(): Iterator<T, any, any>;
        concat<T2>(other: Iterable<T2>): Stream<T | T2>;
        count(): number;
        distinct<Key = T>(by?: (element: T) => Key): Stream<T>;
        every<S>(predicate: (value: T) => value is S): this is Stream<S>;
        every(predicate: (value: T) => unknown): boolean;
        exclude<Key = T>(other: Iterable<T>, key?: (element: T) => Key): Stream<T>;
        filter<S>(predicate: (value: T) => value is S): Stream<S>;
        filter(predicate: (value: T) => unknown): Stream<T>;
        find<S>(predicate: (value: T) => value is S): undefined | S;
        find(predicate: (value: T) => unknown): undefined | T;
        findIndex(predicate: (value: T) => unknown): number;
        flat<D extends number = 1>(depth?: D): FlatStream<T, D>;
        flatMap<U>(callbackfn: (value: T) => U | Iterable<U, any, any>): Stream<U>;
        forEach(callbackfn: (value: T, index: number) => void): void;
        head(): undefined | T;
        includes(searchElement: T): boolean;
        indexOf(searchElement: T, fromIndex?: number): number;
        isEmpty(): boolean;
        iterator(): TreeIterator<T>;
        join(separator?: string): string;
        limit(maxSize: number): Stream<T>;
        map<U>(callbackfn: (value: T) => U): Stream<U>;
        nonNullable(): Stream<NonNullable<T>>;
        reduce(callbackfn: (previousValue: T, currentValue: T) => T): undefined | T;
        reduce<U = T>(
            callbackfn: (previousValue: U, currentValue: T) => U,
            initialValue: U,
        ): U;
        reduceRight(
            callbackfn: (previousValue: T, currentValue: T) => T,
        ): undefined | T;
        reduceRight<U = T>(
            callbackfn: (previousValue: U, currentValue: T) => U,
            initialValue: U,
        ): U;
        some(predicate: (value: T) => unknown): boolean;
        tail(skipCount?: number): Stream<T>;
        toArray(): T[];
        toMap<K = T, V = T>(keyFn?: (e: T) => K, valueFn?: (e: T) => V): Map<K, V>;
        toSet(): Set<T>;
        toString(): string;
    }

    Type Parameters

    • T

    Hierarchy (View Summary)

    Implemented by

    Index

    Methods

    • Returns Iterator<T, any, any>

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

    • Determines whether all members of the stream satisfy the specified test.

      Type Parameters

      • S

      Parameters

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

        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 false, or until the end of the stream.

      Returns this is Stream<S>

    • Parameters

      • predicate: (value: T) => unknown

      Returns boolean

    • 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 elements of the stream that meet the condition specified in a callback function. 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

      • S

      Parameters

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

        Lazily evaluated function checking a condition on stream elements.

      Returns Stream<S>

    • Parameters

      • predicate: (value: T) => unknown

      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>

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

      • OptionalfromIndex: number

        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

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

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

      Parameters

      • OptionalskipCount: number

        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>