pond-ts 0.1.0 → 0.1.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/README.md +66 -3
  2. package/package.json +3 -3
package/README.md CHANGED
@@ -1,9 +1,7 @@
1
- # pond-ts
1
+ # pond-ts - A modern typescript timeseries library
2
2
 
3
3
  TypeScript-first time series primitives built around typed events, typed schemas, and explicit temporal keys.
4
4
 
5
- The package is intended to work in modern Node and frontend projects. The repo toolchain should work on Node 18, and we can use `nvm` to verify against newer stable Node releases when needed.
6
-
7
5
  The library is currently focused on non-streaming analytics:
8
6
 
9
7
  - typed `TimeSeries` construction
@@ -12,6 +10,8 @@ The library is currently focused on non-streaming analytics:
12
10
  - alignment, aggregation, joins, rolling windows, and smoothing
13
11
  - timezone-aware calendar sequences and ingest helpers
14
12
 
13
+ The package is intended to work in modern Node and frontend projects.
14
+
15
15
  ## Install
16
16
 
17
17
  ```sh
@@ -20,6 +20,8 @@ npm install pond-ts
20
20
 
21
21
  ## Build
22
22
 
23
+ The repo toolchain should work on Node 18, but use `nvm` to verify against newer stable Node releases when needed.
24
+
23
25
  ```sh
24
26
  npm run build
25
27
  ```
@@ -90,6 +92,67 @@ event.get('cpu');
90
92
  event.data().host;
91
93
  ```
92
94
 
95
+ ## Worked example
96
+
97
+ This is the kind of flow `pond-ts` is built for: start with typed events, then derive aligned, aggregated, and smoothed analytical views without mutating the original series.
98
+
99
+ ```ts
100
+ import { Sequence, TimeSeries } from 'pond-ts';
101
+
102
+ const schema = [
103
+ { name: 'time', kind: 'time' },
104
+ { name: 'cpu', kind: 'number' },
105
+ { name: 'requests', kind: 'number' },
106
+ { name: 'host', kind: 'string' },
107
+ ] as const;
108
+
109
+ const cpu = TimeSeries.fromJSON({
110
+ name: 'cpu',
111
+ schema,
112
+ rows: [
113
+ ['2025-01-01T00:00:00Z', 0.31, 120, 'api-1'],
114
+ ['2025-01-01T00:01:00Z', 0.44, 135, 'api-1'],
115
+ ['2025-01-01T00:02:00Z', 0.52, 141, 'api-1'],
116
+ ['2025-01-01T00:03:00Z', 0.48, 128, 'api-1'],
117
+ ['2025-01-01T00:04:00Z', 0.63, 166, 'api-1'],
118
+ ],
119
+ });
120
+
121
+ const perMinute = cpu.align(Sequence.every('1m'), {
122
+ method: 'hold',
123
+ });
124
+
125
+ const fiveMinute = cpu.aggregate(Sequence.every('5m'), {
126
+ cpu: 'avg',
127
+ requests: 'sum',
128
+ host: 'last',
129
+ });
130
+
131
+ const rolling = cpu.rolling('3m', {
132
+ cpu: 'avg',
133
+ requests: 'sum',
134
+ });
135
+
136
+ const smoothed = cpu.smooth('cpu', 'ema', {
137
+ alpha: 0.35,
138
+ output: 'cpuTrend',
139
+ });
140
+
141
+ console.log(perMinute.first()?.key().asString());
142
+ console.log(fiveMinute.first()?.data());
143
+ console.log(rolling.last()?.data());
144
+ console.log(smoothed.last()?.get('cpuTrend'));
145
+ ```
146
+
147
+ From one typed source series, you can derive:
148
+
149
+ - aligned interval views for dashboards and joins
150
+ - bucketed aggregates for reporting
151
+ - rolling metrics for short-term behavior
152
+ - smoothed trends for visualization or alerting
153
+
154
+ All of those remain fully typed and immutable.
155
+
93
156
  ## JSON ingest
94
157
 
95
158
  Use `TimeSeries.fromJSON(...)` for external data and ambiguous local timestamps.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pond-ts",
3
- "version": "0.1.0",
3
+ "version": "0.1.4",
4
4
  "description": "TypeScript-first time series primitives",
5
5
  "license": "MIT",
6
6
  "repository": {
@@ -24,8 +24,8 @@
24
24
  ],
25
25
  "scripts": {
26
26
  "build": "tsc -p tsconfig.json",
27
- "format": "prettier --write .",
28
- "format:check": "prettier --check .",
27
+ "format": "prettier --write \"src/**/*.ts\" \"test/**/*.ts\" \"test-d/**/*.ts\"",
28
+ "format:check": "prettier --check \"src/**/*.ts\" \"test/**/*.ts\" \"test-d/**/*.ts\"",
29
29
  "prepack": "npm run build",
30
30
  "test": "npm run test:type && npm run test:runtime",
31
31
  "test:runtime": "vitest run",