JSPM

  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 58
  • Score
    100M100P100Q77073F
  • License MIT

collect stats about numbers

Package Exports

  • stats-collector

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (stats-collector) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

stats-collector

NPM version Build Status Code Climate Coverage Status Dependency Status devDependency Status

NPM

Description

Collect stats about numbers. This library provides a few different default collectors, but allows you to add your own "stat collectors" by exposing an API that lets you pass in reducer-like functions that act on numbers passed to it.

For examples and api documentation, continue reading below.

Node.js Library

Getting Started

Install the module with: npm install stats-collector

Usage (Method 1)

import * as lib from 'stats-collector';
const statsCollector = new lib.StatsCollector();
statsCollector.update([1,2,3,4,5]);
console.log(statsCollector.get());

Usage (Method 2)

import StatsCollector from 'stats-collector/lib/StatsCollector';
const statsCollector = new StatsCollector();
statsCollector.update([1,2,3,4,5]);
console.log(statsCollector.get());

Usage (Different types of collectors)

import * as lib from 'stats-collector';
const c1 = new lib.BaseStatsCollector();      // 0 default collectors
const c2 = new lib.BasicStatsCollector();     // 5 default collectors
const c3 = new lib.StatsCollector();          // 8 default collectors
const c4 = new lib.AdvancedStatsCollector();  // 21 default collectors
const collectors = lib.collectors; // some collector functions
const filters = lib.filters; // some filter functions
console.log(c1.get(), c2.get(), c3.get(), c4.get(), collectors, filters);

Example Output

The following table shows you the results of initializing a stats collector, then running the following statments:

statsCollector.update([1, 2, 3, 4, 5]);
const results = statsCollector.get();
Collector Type Results
BaseStatsCollector {}
BasicStatsCollector {
 "count": 5,
 "max": 5,
 "mean": 3,
 "min": 1,
 "sum": 15
}
StatsCollector {
 "count": 5,
 "max": 5,
 "mean": 3,
 "min": 1,
 "powerSumAvg_running": 11,
 "standardDeviation_running": 1.5811388300841898,
 "sum": 15,
 "variance_running": 2.5
}
AdvancedStatsCollector {
 "count": 5,
 "count_even": 2,
 "count_float": 0,
 "count_integer": 5,
 "count_negative": 0,
 "count_nonZero": 5,
 "count_odd": 3,
 "count_positive": 5,
 "count_prime": 3,
 "count_zero": 0,
 "max": 5,
 "mean": 3,
 "min": 1,
 "powerSumAvg_running": 11,
 "standardDeviation_running": 1.5811388300841898,
 "standardDeviation_stable": 1.5811388300841898,
 "sum": 15,
 "sumOfSquaredDeviations_stable": 10,
 "variance_running": 2.5,
 "variance_stable": 2.5
}

API Documentation

Read the API Docs by visiting the project site here:

See Also

License

Copyright (c) 2015 skratchdot
Licensed under the MIT license.