Stats Collector Reference Source Repository
import BaseStatsCollector from 'stats-collector/lib/BaseStatsCollector'
public class | source

BaseStatsCollector

A stat collector that initially includes no collector functions.

Example:

const statsCollector = new BaseStatsCollector();
statsCollector.addCollector({name: 'custom', onUpdate: fn});
statsCollector.update([1, 2, 3, 4, 5]);
statsCollector.get();

Constructor Summary

Public Constructor
public

Method Summary

Public Methods
public

Add a collector function that can process data when update() or get() is called.

public

addIgnore(name: *)

public

get(): *

public

reset()

public

update(values: ...*)

Public Constructors

public constructor source

Public Methods

public addCollector(collector: Object): undefined source

Add a collector function that can process data when update() or get() is called.

Params:

NameTypeAttributeDescription
collector Object

An object with the following properties:

  • name - [String] The name of the collector
  • initialValue - [any] The initial value if update() has never been called
  • requirements - [Array] An array of collector names that must be added before this collector
  • onUpdate - [Function]
  • onGet - [Function]

Return:

undefined

Example:

const statCollector = new BaseStatsCollector();
statCollector.addCollector({
  name: 'test-sum',
  initialValue: 0,
  onUpdate: function (prev, state, val) { return prev + val; }
});

public addIgnore(name: *) source

Params:

NameTypeAttributeDescription
name *

public get(): * source

Return:

*

public reset() source

public update(values: ...*) source

Params:

NameTypeAttributeDescription
values ...*