Options
All
  • Public
  • Public/Protected
  • All
Menu

Module Op<A, R, S>

A Collector taking input types of type A and returning results of type R

Type parameters

  • A

    the input element type

  • R

    the result type

  • S

Index

Type aliases

MapOp

MapOp: Op<A, any>[] & object

Functions

combine

  • combine<A, CR>(...ops: MapOp<A, CR>): Op<A, CR>
  • Returns a Collector running the provided Collectors are run in parallel. The results are collected into an array.

    Type parameters

    • A

      the input element type

    • CR: [unknown, unknown, Array]

      a tuple corresponding to the output types of the input collectors

    Parameters

    • Rest ...ops: MapOp<A, CR>

      a number of Collectors taking the same type of elements as input

    Returns Op<A, CR>

combineWith

  • combineWith<A, CR, GR>(combineFun: function, ...ops: MapOp<A, CR>): Op<A, GR>
  • Returns a Collector where the provided GenCollectors are run in parallel. The given combineFun is applied to the array of results. Note: due to type system limitations only the type of the first other collector is kept

    Type parameters

    • A

      the input element type

    • CR: [unknown, unknown, Array]

      a tuple corresponding to the output types of the input collectors

    • GR

      the result type of the combineFun function

    Parameters

    • combineFun: function

      a function that takes the tupled output of all provided collectors, and combines them into one result value

        • (...results: CR): GR
        • Parameters

          • Rest ...results: CR

          Returns GR

    • Rest ...ops: MapOp<A, CR>

      a number of Collectors taking the same type of elements as input

    Returns Op<A, GR>

create

  • create<A, R>(definition: object): Op<A, R>
  • Creates a new Collector object from element type A to result type R

    Type parameters

    • A

      the input element type

    • R

      the state and result type

    Parameters

    • definition: object

    Returns Op<A, R>

createState

  • createState<A, S, R>(definition: object): StateOp<A, S, R>

fixed

  • fixed<R>(result: R): Op<any, R>

pipe

  • pipe<A, R, R2>(op1: Op<A, R>, op2: Op<R, R2>): Op<A, R2>
  • Returns a collector that feeds all input to the first col1 collector, and for each input element takes the output value from col1 and feeds this value to col2. The output value is the value resulting from col2.

    Type parameters

    • A

      the input element type

    • R

      the result type of col1

    • R2

      the result type of col2

    Parameters

    • op1: Op<A, R>

      the collector that receives the input

    • op2: Op<R, R2>

      the collector that produces the output

    Returns Op<A, R2>

Accessors

createInitState

  • get createInitState(): function

escape

  • get escape(): undefined | function

nextState

  • get nextState(): function

stateToResult

  • get stateToResult(): function

Methods

appendInput

  • Returns a Collector where the given elems are appended to the input received. Note: since the appending happens when the state is retrieved, getting the result multiple times can give unpredictable results.

    Parameters

    • Rest ...elems: NonEmpty<A>

      the elements to prepent

    Returns Op<A, R>

distinctByInput

  • distinctByInput<K>(keyFun: function): Op<A, R>
  • Returns a Collector that processes every input element for which the given keyFun returns the same key value at most once.

    Type parameters

    • K

      the element key type

    Parameters

    • keyFun: function

      a function taking an input element and its index, and returning a key

        • (value: A, index: number): K
        • Parameters

          • value: A
          • index: number

          Returns K

    Returns Op<A, R>

distinctInput

  • distinctInput(): Op<A, R>

dropInput

  • dropInput(amount: number): Op<A, R>

dropLastInput

  • dropLastInput(amount: number): Op<A, R>

dropWhileInput

  • dropWhileInput(pred: Pred<A>): Op<A, R>

filterChangedInput

  • filterChangedInput(): Op<A, R>

filterInput

  • filterInput(pred: Pred<A>): Op<A, R>

intersperseInput

  • intersperseInput(elem: A): Op<A, R>

mapInput

  • mapInput<A2>(mapFun: MapFun<A2, A>): Op<A2, R>
  • Returns a Collector where the input is mapped from a source type A2 to the expected input elements of type A.

    Type parameters

    • A2

      the new source/input type

    Parameters

    • mapFun: MapFun<A2, A>

      a function mapping from the new input type A2 to the expected input type A

    Returns Op<A2, R>

mapResult

  • mapResult<R2>(mapFun: function): Op<A, R2>
  • Returns a Collector where the output value(s) are mapped using the given mapFun

    Type parameters

    • R2

      the new output type

    Parameters

    • mapFun: function

      a function from current output type R to new output type R2

        • (result: R): R2
        • Parameters

          • result: R

          Returns R2

    Returns Op<A, R2>

monitorInput

  • Performs given monitorEffect for each input element. By default does a console.log with the given tag.

    Parameters

    • Default value tag: string = ""

      a tag to use with logging

    • Default value effect: MonitorEffect<[A, S]> = defaultMonitorEffect

      the effect to perform for each input element

    Returns Op<A, R>

patchElemInput

  • patchElemInput(elem: A, remove: number, insert?: Iterable<A>, amount?: undefined | number): Op<A, R>
  • Returns a Collector where, at the occurence of given elem element, remove elements are skipped, and insert elements are inserted, at most amount times.

    Parameters

    • elem: A

      the element to find

    • remove: number

      the amount of elements to skip when the element is found

    • Optional insert: Iterable<A>

      the optional iterable to insert when the element is found

    • Optional amount: undefined | number

      the maximum amount of time to replace an element

    Returns Op<A, R>

patchWhereInput

  • patchWhereInput(pred: Pred<A>, remove: number, insert?: undefined | function, amount?: undefined | number): Op<A, R>
  • Returns a Collector that skips remove elements at those input elements for which pred returns true, and then inserts th e optional iterable resulting from calling insert with the found element and its index, at most amount times.

    Parameters

    • pred: Pred<A>

      the predicate over input elements

    • remove: number

      the amount of elements to skip when pred is true

    • Optional insert: undefined | function

      the iterable elements to insert when pred is true

    • Optional amount: undefined | number

      the maximum amount of times to replace an input element

    Returns Op<A, R>

prependInput

sampleInput

  • sampleInput(nth: number): Op<A, R>

sliceInput

  • sliceInput(from: number, amount: number): Op<A, R>
  • Returns a Collector that only process amount elements from the given from index of the input elements.

    Parameters

    • from: number

      the index to start processing elements

    • amount: number

      the amount of elements to process

    Returns Op<A, R>

takeInput

  • takeInput(amount: number): Op<A, R>

takeLastInput

  • takeLastInput(amount: number): Op<A, R>

takeWhileInput

  • takeWhileInput(pred: Pred<A>): Op<A, R>

Static create

  • create<Elem, St, Res>(definition: object): StateOp<Elem, St, Res>
  • Creates a new Collector object from element type A to result type R

    typeparam

    the input element type

    typeparam

    the intermediate state type

    typeparam

    the result type

    Type parameters

    • Elem

    • St

    • Res

    Parameters

    • definition: object

      the definition of the state collector, containing:

      • initState: the initial state of the Collector, optionally lazy
      • nextState: a function taking the current state S and the next element A and returns the next state S
      • stateToResult: a function that takes a state S and maps it to a result R
      • escape?: a predicate over a state S indicating whether its value can still ever change

    Returns StateOp<Elem, St, Res>

Generated using TypeDoc