import type { Fn } from "@thi.ng/api" ; import { identity } from "@thi.ng/compose/identity" ; import type { Reducer } from "./api.js" ; import { count } from "./count.js" ; import { groupByMap } from "./group-by-map.js" ; import { $$reduce } from "./reduce.js" ; export function frequencies < A > ( ) ; export function frequencies < A > ( xs ) ; export function frequencies < A , B > ( key ) ; export function frequencies < A , B > ( key , xs ) ; export function frequencies ( ... args ) { return ( $$reduce ( frequencies , args ) || groupByMap ( { key : args [ 0 ] || identity , group : count ( ) } ) ) ; }