namespace Reducer
A Reducer
is a stand-alone calculation that takes input values of type I, and, when requested, produces an output value of type O.
Companion type: Reducer<I,O>
Interfaces
Name | Description |
---|---|
Reducer.Impl<I,O,S> | The Implementation interface for a Reducer , which also exposes the internal state type. |
Reducer.Instance<I,O> | A reducer instance that manages its own state based on the reducer definition that was used to create this instance. |
Classes
Name | Description |
---|---|
Base | A base class that can be used to easily create Reducer instances. |
InstanceImpl | The default Reducer.Impl implementation. |
InvalidCombineShapeError | undocumented |
ReducerHaltedError | undocumented |
Functions
combine
Returns a Reducer
that combines multiple input reducers
according to the given "shape" by providing input values to all of them and collecting the outputs in the shape.
combine
Reducer
that combines multiple input reducers
according to the given "shape" by providing input values to all of them and collecting the outputs in the shape.constant
Returns a Reducer
that always outputs the given value
, and does not accept input values.
constant
Reducer
that always outputs the given value
, and does not accept input values.contains
Returns a Reducer
that outputs false as long as the given elem
has not been encountered the given amount
of times in the input values, true otherwise.
contains
Reducer
that outputs false as long as the given elem
has not been encountered the given amount
of times in the input values, true otherwise.containsSlice
Returns a Reducer
that returns true if the input values contain the given slice
sequence amount
times. Otherwise, returns false.
containsSlice
Reducer
that returns true if the input values contain the given slice
sequence amount
times. Otherwise, returns false.create
Returns a Reducer
with the given options:
create
Reducer
with the given options:createMono
Returns a Reducer
of which the input, state, and output types are the same.
createMono
Reducer
of which the input, state, and output types are the same.createOutput
Returns a Reducer
of which the state and output types are the same.
createOutput
Reducer
of which the state and output types are the same.endsWithSlice
Returns a Reducer
that returns true if the last input values match the given slice
values repeated amount
times. Otherwise, returns false.
endsWithSlice
Reducer
that returns true if the last input values match the given slice
values repeated amount
times. Otherwise, returns false.equals
Returns a Reducer
that ouputs true when the received elements match the given other
stream source according to the eq
instance, false otherwise.
equals
Reducer
that ouputs true when the received elements match the given other
stream source according to the eq
instance, false otherwise.every
Returns a Reducer
that ouputs true as long as all input values satisfy the given pred
, false otherwise.
every
Reducer
that ouputs true as long as all input values satisfy the given pred
, false otherwise.fold
Returns a Reducer
that uses the given init
and next
values to fold the input values into result values.
fold
Reducer
that uses the given init
and next
values to fold the input values into result values.join
Returns a Reducer
that joins the given input values into a string using the given options.
join
Reducer
that joins the given input values into a string using the given options.some
Returns a Reducer
that ouputs false as long as no input value satisfies given pred
, true otherwise.
some
Reducer
that ouputs false as long as no input value satisfies given pred
, true otherwise.startsWithSlice
Returns a Reducer
that returns true if the first input values match the given slice
values repeated amount
times. Otherwise, returns false.
startsWithSlice
Reducer
that returns true if the first input values match the given slice
values repeated amount
times. Otherwise, returns false.toArray
Returns a Reducer
that collects received input values in an array, and returns a copy of that array as an output value when requested.
toArray
Reducer
that collects received input values in an array, and returns a copy of that array as an output value when requested.toJSMap
Returns a Reducer
that collects received input tuples into a mutable JS Map, and returns a copy of that map when output is requested.
toJSMap
Reducer
that collects received input tuples into a mutable JS Map, and returns a copy of that map when output is requested.toJSMultiMap
Returns a Reducer
that collects received input tuples into a mutable JS multimap, and returns a copy of that map when output is requested.
toJSMultiMap
Reducer
that collects received input tuples into a mutable JS multimap, and returns a copy of that map when output is requested.toJSObject
Returns a Reducer
that collects 2-tuples containing keys and values into a plain JS object, and returns a copy of that object when output is requested.
toJSObject
Reducer
that collects 2-tuples containing keys and values into a plain JS object, and returns a copy of that object when output is requested.toJSSet
Returns a Reducer
that collects received input values into a mutable JS Set, and returns a copy of that map when output is requested.
toJSSet
Reducer
that collects received input values into a mutable JS Set, and returns a copy of that map when output is requested.Constants
Name | Description |
---|---|
and | A Reducer that takes boolean values and outputs true if all input values are true, and false otherwise. |
average | A Reducer that calculates the average of all given numberic input values. |
count | A Reducer that remembers the amount of input items provided. |
first | Returns a Reducer that remembers the first input value. |
groupBy | Returns a Reducer that uses the valueToKey function to calculate a key for each value, and feeds the tuple of the key and the value to the collector reducer. Finally, it returns the output of the collector . If no collector is given, the default collector will return a JS multimap of the type Map<K, V[]> . |
isEmpty | A Reducer that outputs true if no input values are received, false otherwise. |
last | Returns a Reducer that remembers the last input value. |
max | Returns a Reducer that remembers the maximum value of the numberic inputs. |
maxBy | Returns a Reducer that remembers the maximum value of the inputs using the given compFun to compare input values |
min | Returns a Reducer that remembers the minimum value of the numberic inputs. |
minBy | Returns a Reducer that remembers the minimum value of the inputs using the given compFun to compare input values |
nonEmpty | A Reducer that outputs true if one or more input values are received, false otherwise. |
or | A Reducer that takes boolean values and outputs true if one or more input values are true, and false otherwise. |
partition | Returns a Reducer that splits the incoming values into two separate outputs based on the given pred predicate. Values for which the predicate is true are fed into the collectorTrue reducer, and other values are fed into the collectorFalse instance. If no collectors are provided the values are collected into arrays. |
pipe | Returns a Reducer instance that first applies this reducer, and then applies the given next reducer to each output produced by the previous reducer. |
product | A Reducer that calculates the product of all given numeric input values. |
race | Returns a Reducer that feeds incoming values to all reducers in the provided reducers source, and halts when the first reducer in the array is halted and returns the output of that reducer. Returns the otherwise value if no reducer is yet halted. |
single | Returns a Reducer that only produces an output value when having receives exactly one input value, otherwise will return the otherwise value or undefined. |
sum | A Reducer that sums all given numeric input values. |