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

Hierarchy

  • LazyStream

Implements

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 an observable of the given stream

    Returns Iterator<T, any, undefined>

  • 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

  • Collect the elements with a collector given There are a number of collectors provided

    Parameters

    Returns any

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

  • 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

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

    • StreamMapper

    Parameters

    • fn: StreamMapper | ArrayMapper<any>

    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>

  • returns the next element in the stream difference to next is, that the internal data position is not changed, so next still will deliver the next item from the current data position. Look ahead is mostly needed internally by possible endless data constructs which have no fixed data boundary, or index positions. (aka infinite sets, or flatmapped constructs)

    Parameters

    • cnt: number = 1

    Returns T | ITERATION_STATUS

  • maps a single element into another via fn

    Type Parameters

    • R

    Parameters

    • fn: Mappable<T, R>

      function which takes one element in and returns another

    Returns LazyStream<any>

  • Parameters

    • fn: Matchable<T>

    Returns 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

      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>

  • Type Parameters

    • T

    Parameters

    • data: { [key: string]: T }
      • [key: string]: T

    Returns LazyStream<[string, T]>

Generated using TypeDoc