import type { TxLike } from "./api.js" ; import { ensureTransducer } from "./ensure.js" ; import { push } from "./push.js" ; import { isReduced } from "./reduced.js" ; remarks example param tx export const step = < A , B > ( tx ) : ( ( x : A ) => B | B [ ] ) => { const { 1 : complete , 2 : reduce } = ensureTransducer ( tx ) ( push ( ) ) ; let done = false ; return ( x ) => { if ( ! done ) { let acc = reduce ( [ ] , x ) ; done = isReduced ( acc ) ; if ( done ) { acc = complete ( acc . deref ( ) ) ; } return acc . length === 1 ? acc [ 0 ] : acc . length > 0 ? acc : undefined ; } } ; } ;