import { mean } from 'lodash' ; export class TypedWindow < T > { private window : Array < T > ; constructor ( private size , private minSize , private nullValue ) { this . window = [ ] ; } add ( value ) { if ( value == this . nullValue ) return ; this . window . push ( value ) ; if ( this . window . length > this . size ) this . window . shift ( ) ; } mean ( ) { if ( this . window . length < this . minSize ) { return - 1 ; } else { return mean ( this . window ) ; } } get Window ( ) { return this . window ; } }