export function $isTypedArray < T extends object > ( array , constructor ) { return array . every ( item => item instanceof constructor ) ; } export function sum ( array ) { return array . reduce ( ( n , x ) => n + x , 0 ) ; } if ( typeof Array . prototype . flatMap == "undefined" ) { Array . prototype . flatMap = function ( callback , thisArg ? ) : any { thisArg ??= this ; let aggregate = ( agg , next , index , arr ) : unknown [ ] => { agg . push ( ... callback ( next , index , arr ) ) ; return agg ; } ; return thisArg . reduce ( aggregate , [ ] ) ; } ; }