import type { Comparator , Fn , IObjectOf } from "@thi.ng/api" ; import type { Reduced } from "./reduced.js" ; export type Transducer < A , B > = ( rfn : Reducer < any , B > ) => Reducer < any , A > ; export type TxLike < A , B > = Transducer < A , B > | IXform < A , B > ; export type ReductionFn < A , B > = ( acc : A , x : B ) => A | Reduced < A > ; export interface Reducer < A , B > extends Array < any > { [ 0 ] : ( ) => A ; [ 1 ] : ( acc : A ) => A ; [ 2 ] : ReductionFn < A , B > ; } /**
 * Interface for types able to provide some internal functionality (or
 * derive some related transformation) as  Transducer .
 * Implementations of this interface can be directly passed to all
 * functions in this package where a `Transducer` arg is expected.
 *
 *  example export interface IXform < A , B > { /**
     * Returns type specific operation as transducer. Internally called
     * by functions in this package which expect transducer args. Users
     * don't need to call this manually.
     */ xform ( ) : Transducer < A , B > ; } export interface IReducible < A , B > { $reduce ( rfn , acc ) : A | Reduced < A > ; } export type TransformFn = ( x : any ) => any ; export type TransformSubSpec = IObjectOf < TransformSpec | TransformFn > ; export interface TransformSpec extends Array < any > { [ 0 ] : TransformFn ; [ 1 ] ? : TransformSubSpec ; } export interface SortOpts < A , B > { /**
     * Sort key lookup function.
     * Default: `identity`
     */ key : Fn < A , B > ; /**
     * Comparator.
     * Default: `thi.ng/compare/compare`
     */ compare : Comparator < B > ; } export interface GroupByOpts < SRC , KEY , GROUP > { key : Fn < SRC , KEY > ; group : Reducer < GROUP , SRC > ; }