averaged-timeseries

1.4.0 • Public • Published

This is a tiny in memory non persistent database library. It is made for aggregating timeseries data and storing it as averages/sums. Example usage:

See index.spec.js for more examples.

API

index

In memory timeseries database with averaged/summed values to reduce performance footprint

Parameters

  • options object? Options object, can be left as blank to use defaults, see index.spec.js for details
    • options.maxEntries number? how many entries to store in the timeseries, defaults to 3600
    • options.entriesPerSecond number? how many times a second to move the timeseries, default 1, can be less than 1 for slower updates
    • options.mergeMode string? how to merge multiple entries in one tick, default is "average"
    • options.data object? starting data for timeSeries, defaults to {}
  • log function? Logging function, can be left as undefined for no logging

Returns object timeSeries

Meta

  • author: Daniel Vestøl
  • license: MIT

add

Adds timeseries data to a collection

Parameters

Examples

let series = new timeSeries();
series.add({
  key: "apples",
  value: 3,
});

get

Retrieves timeseries data

Parameters

  • datapoints number the number of datapoints to retrieve, has to be less than size of collection
  • key string name of collection to retrieve

Returns array of objects like [{key: "string", value: number}]

clear

Clears all data

Examples

new timeSeries().clear()

Package Sidebar

Install

npm i averaged-timeseries

Weekly Downloads

3

Version

1.4.0

License

MIT

Last publish

Collaborators

  • danielv123