import { Reducer } from "https://deno.land/x/rimbu@0.13.1/common/internal.ts";
const { createOutput } = Reducer;
Returns a Reducer
of which the state and output types are the same.
Examples
Example 1
Example 1
const boolToString = Reducer
.createOutput(
'',
(current, value: boolean) => current + (value ? 'T' : 'F')
)
const result = Stream.of(true, false, true)).reduce(boolToString)
console.log+(result)
// => 'TFT'
Type Parameters
optional
O = IParameters
- returns the next state value based on the given inputs:
- current: the current state
- next: the current input value
- index: the input index value
- halt: function that, when called, ensures no more elements are passed to the reducer