mona-dish
    Preparing search index...

    Class LazyStream<T>

    Lazy implementation of a Stream The idea is to connect the intermediate streams as datasources like a linked list with reverse referencing and for special operations like filtering flatmapping have intermediate datasources in the list with specialized functions.

    Sort of a modified pipe valve pattern the streams are the pipes the intermediate data sources are the valves

    We then can use passed in functions to control the flow in the valves

    That way we can have a lazy evaluating stream

    So if an endpoint requests data a callback trace goes back the stream list which triggers an operation upwards which sends data down the drain which then is processed and filtered until one element hits the endpoint.

    That is repeated, until all elements are processed or an internal limit is hit.

    Type Parameters

    • T

    Implements

    Index

    Constructors

    Properties

    _limits: number = -1
    pos: number = -1

    Accessors

    • get value(): T[]

      returns the stream collected into an array (90% use-case abbreviation

      Returns T[]

    Methods

    • returns true if all elmements produce true on a call to fn(element)

      Parameters

      • fn: Matchable<T>

      Returns boolean

    • returns true if there is at least one element where a call fn(element) produces true

      Parameters

      • fn: Matchable<T>

      Returns boolean

    • returns the current element, returns the same element as the previous next call if there is no next before current called then we will call next as initial element

      Returns ITERATION_STATUS | T

    • filtering, takes an element in and is processed by fn. If it returns false then further processing on this element is skipped if it returns true it is passed down the chain.

      Parameters

      • Optionalfn: Matchable<T>

      Returns LazyStream<T>

    • Takes an element in and returns a set of something the set then is flatted into a single stream to be further processed

      Type Parameters

      • R

      Parameters

      • Optionalfn: (data: T) => any[] | R

      Returns LazyStream<any>

    • Returns the last stream element (note in endless streams without filtering and limiting you will never reach that point hence producing an endless loop)

      Returns Optional<T>

    • looks ahead cnt without changing the internal data "pointers" of the data source (this is mostly needed by possibly infinite constructs like lazy streams, because they do not know by definition their boundaries)

      Parameters

      • cnt: number = 1

        the elements to look ahead

      Returns ITERATION_STATUS | T

      either the element or ITERATION_STATUS.EO_STRM if we hit the end of the stream before finding the "cnt" element

    • maps a single element into another via fn

      Type Parameters

      • R

      Parameters

      • Optionalfn: Mappable<T, R>

        function which takes one element in and returns another

      Returns LazyStream<any>

    • Parameters

      • fn: Matchable<T>

      Returns ITERATION_STATUS | T

    • returns true if no elmements produce true on a call to fn(element)

      Parameters

      • fn: Matchable<T>

      Returns boolean

    • Perform the operation fn on a single element in the stream at a time then pass the stream over for further processing This is basically an intermediate point in the stream with further processing happening later, do not use this method to gather data or iterate over all date for processing (for the second case each has to be used)

      Parameters

      • fn: IteratableConsumer<T>

        the processing function, if it returns false, further processing is stopped

      Returns LazyStream<T>

    • functional reduce... takes two elements in the stream and reduces to one from left to right

      Type Parameters

      • V

      Parameters

      • fn: Reducable<T, V>

        the reduction function for instance (val1,val2) => val1l+val2

      • startVal: T | V | null = null

        an optional starting value, if provided the the processing starts with this element and further goes down into the stream, if not, then the first two elements are taken as reduction starting point

      Returns Optional<T | V>

    • sort on the stream, this is a special case of an endpoint, so your data which is fed in needs to be limited otherwise it will fail it still returns a stream for further processing

      Parameters

      • comparator: Comparator<T>

      Returns IStream<T>

    • chunk-safe factory, takes the backing array directly instead of spreading it into the call (LazyStream.of(...largeArray) overflows the argument stack on large arrays)

      Type Parameters

      • T

      Parameters

      • data: T[]

        the array to stream over

      Returns LazyStream<T>