import type { Nullable } from "@thi.ng/api" ; import type { Reducer , Transducer } from "./api.js" ; import { compR } from "./compr.js" ; import { ensureReduced , isReduced , unreduced } from "./reduced.js" ; remarks If, during processing, the transducer is given a wrapped reduced
 * input iterable, it will still be processed as normal, but then
 * immediately triggers early termination by wrapping its own result in
 *  reduced . E.g. this behavior allows a  {@link (mapcat:1)} user
 * functions to benefit from reduced results.
 *
 * Also see:
 * -  concat * -  {@link (mapcat:1)} example param rfn export const cat = < T > ( ) : Transducer < Nullable < Iterable < T > > , T > => ( rfn ) => { const r = rfn [ 2 ] ; return compR ( rfn , ( acc , x ) => { if ( x ) { for ( let y of unreduced ( x ) ) { acc = r ( acc , y ) ; if ( isReduced ( acc ) ) { break ; } } } return isReduced ( x ) ? ensureReduced ( acc ) : acc ; } ) ; } ;