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 detailsoptions.maxEntries
number? how many entries to store in the timeseries, defaults to 3600options.entriesPerSecond
number? how many times a second to move the timeseries, default 1, can be less than 1 for slower updatesoptions.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 = ;series;
get
Retrieves timeseries data
Parameters
datapoints
number the number of datapoints to retrieve, has to be less than size of collectionkey
string name of collection to retrieve
Returns array of objects like [{key: "string", value: number}]
clear
Clears all data
Examples
clear