UNPKG

sinch-rtc

Version:

RTC JavaScript/Web SDK

50 lines (49 loc) 1.64 kB
/** * Collection simplifying handling buffer of numeric values with maximum capacity. * StatsBuffer keeps at most maxSize values. When a new value is prepended the oldest one is removed * if size of the buffer exceeds the size limit. */ export declare class StatsBuffer { private maxSize; private samplesCountForWarning; private threshold; private buffer; private bufferSum; /** * Creates a new instance of StatsBuffer. * @param maxSize - maximum size of the buffer. * @param samplesCountForWarning - number of values in the buffer that need to be above the threshold to set isAboveThreshold flag to true. * @param threshold - threshold value. */ constructor(maxSize: number, samplesCountForWarning: number, threshold: number); /** * Creates a new instance of StatsBuffer. * @param maxSize - maximum size of the buffer. */ constructor(maxSize: number); /** * True if buffer reached maximum capacity, false otherwise. */ get isFull(): boolean; /** * True if all the values in the buffer are equal to 0.0, false otherwise. */ get allZeros(): boolean; /** * True if `samplesCountForWarning` values kept in buffer are above threshold,false otherwise. */ get isAboveThreshold(): boolean; /** * Average value of the numbers in the buffer. */ get average(): number; /** * Standard deviation of the numbers in the buffer. */ get standardDeviation(): number; /** * Adds a new value to the buffer. * @param value - value to add. */ add(value: number): void; }