Getting Started
Install
npm install pond-ts
First series
import { TimeSeries } from 'pond-ts';
const schema = [
{ name: 'time', kind: 'time' },
{ name: 'cpu', kind: 'number' },
{ name: 'host', kind: 'string' },
{ name: 'healthy', kind: 'boolean' },
] as const;
const series = new TimeSeries({
name: 'cpu',
schema,
rows: [
[new Date('2025-01-01T00:00:00.000Z'), 0.42, 'api-1', true],
[new Date('2025-01-01T00:01:00.000Z'), 0.51, 'api-2', true],
],
});
const event = series.at(1);
if (!event) {
throw new Error('missing event');
}
console.log(event.key().asString());
console.log(event.get('cpu'));
console.log(event.data().host);
What happens during construction?
Pond validates and normalizes input rows against the supplied schema.
- the first column becomes a temporal key
- payload columns become typed event data
- the series becomes an ordered immutable collection of events
Typical next steps
After construction, the most common operations are:
- selecting or renaming columns
- aligning onto a sequence
- aggregating into reporting buckets
- computing rolling windows
- smoothing a numeric signal
import { Sequence } from 'pond-ts';
const aligned = series.align(Sequence.every('1m'), {
method: 'hold',
});