import { Reducer } from "https://deno.land/x/rimbu@1.2.0/core/mod.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
init: (initHalt: () => void) => O
- the initial state value
- 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