import type { Fn2 } from "@thi.ng/api" ; import type { Reducer , Transducer } from "./api.js" ; import { compR } from "./compr.js" ; import { __iter } from "./iterator.js" ; /**
 * Transducer. Similar to  {@link (map:1)} , but given `fn` takes two
 * arguments: `index` and `value` to transform.
 *
 *  remarks example param fn param offset export function mapIndexed < A , B > ( fn , offset ? ) ; export function mapIndexed < A , B > ( fn , src ) ; export function mapIndexed < A , B > ( fn , offset , src ) ; export function mapIndexed < A , B > ( ... args ) { return ( __iter ( mapIndexed , args ) || ( ( rfn ) => { const r = rfn [ 2 ] ; const fn = args [ 0 ] ; let i = args [ 1 ] || 0 ; return compR ( rfn , ( acc , x ) => r ( acc , fn ( i ++ , x ) ) ) ; } ) ) ; }