mona-dish
    Preparing search index...

    Class Stream<T>

    A simple typescript based reimplementation of streams

    This is the early eval version for a lazy eval version check, LazyStream, which is api compatible to this implementation, however with the benefit of being able to provide infinite data sources and generic data providers, the downside is, it might be a tad slower in some situations

    Type Parameters

    • T

    Implements

    Index

    Constructors

    Properties

    _limits: number = -1
    value: T[]

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

    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

    • Iterate over all elements in the stream and do some processing via fn

      Parameters

      • fn: (data: T, pos?: number) => boolean | void

        takes a single element and if it returns false then further processing is stopped

      Returns void

    • 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: (data: T) => boolean

      Returns Stream<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 Stream<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: (data: T) => R

        function which takes one element in and returns another

      Returns Stream<R>

    • 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: (data: T, pos?: number) => boolean | void

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

      Returns Stream<T>

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

      Type Parameters

      • V

      Parameters

      • fn: Reducable<T, T | V>

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

      • startVal: 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 (Stream.of(...largeArray) overflows the argument stack on large arrays)

      Type Parameters

      • T

      Parameters

      • data: T[]

        the array to stream over

      Returns Stream<T>

    • Type Parameters

      • T

      Parameters

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

      Returns Stream<[string, T]>