import { Observer , Accessor } from "./observer" ; function _mean ( ) { let total ; let count ; return { observe : ( value , idx ) => { if ( idx === 0 ) { total = value ; } else { total += value ; } count = idx ; } , peek : ( ) => total / ( count + 1 ) } ; } export type MeanAccessor < T > = ( row : T , currentIndex : number ) => number ; export function mean ( ) ; export function mean < T = any > ( callbackFn ) ; export function mean < T = any > ( callbackFn ? ) { return callbackFn ? Accessor ( _mean , callbackFn ) : _mean ( ) ; }