{"library":"pondjs","title":"Pond.js","description":"Pond.js is a JavaScript and TypeScript library built on `immutable.js`, providing robust, immutable data structures and processing capabilities for time-based data. It unifies the handling of time ranges, events, collections, and time series through specialized types like `TimeRange`, `TimeEvent`, and `TimeSeries`. The library also offers a powerful `Pipeline` API for advanced batch and stream processing, supporting operations such as windowing, grouping, and aggregation. Currently at version 0.9.0, Pond.js is actively developed and ships with comprehensive TypeScript declarations, with the project having been rewritten in TypeScript for its upcoming v1.0 alpha. Its focus on immutability and specialized time-based structures differentiates it for applications requiring consistent and reliable time-series data management.","language":"javascript","status":"active","last_verified":"Sun Apr 19","install":{"commands":["npm install pondjs"],"cli":null},"imports":["import { TimeSeries } from 'pondjs'","import { TimeRange } from 'pondjs'","import { Pipeline } from 'pondjs'"],"auth":{"required":false,"env_vars":[]},"quickstart":{"code":"import { TimeSeries, TimeEvent, Collection, TimeRange } from 'pondjs';\n\n// Example weather data for demonstration\nconst weatherData = new Collection([\n  new TimeEvent(new Date('2024-01-01T00:00:00Z'), { value: 60 }),\n  new TimeEvent(new Date('2024-01-01T01:00:00Z'), { value: 62 }),\n  new TimeEvent(new Date('2024-01-01T02:00:00Z'), { value: 65 }),\n  new TimeEvent(new Date('2024-01-02T00:00:00Z'), { value: 58 }),\n  new TimeEvent(new Date('2024-01-02T01:00:00Z'), { value: 60 }),\n  new TimeEvent(new Date('2024-01-02T02:00:00Z'), { value: 63 }),\n  new TimeEvent(new Date('2024-01-03T00:00:00Z'), { value: 55 })\n]);\n\nconst timeseries = new TimeSeries({\n  name: 'temperature',\n  events: weatherData.toArray(),\n  columns: ['time', 'value']\n});\n\n// Define aggregation function for average\nconst avg = (events: TimeEvent[]) => {\n  if (events.length === 0) {\n    return null;\n  }\n  const sum = events.reduce((acc, event) => acc + event.get('value'), 0);\n  return sum / events.length;\n};\n\n// Perform daily average rollup on the 'value' column\nconst dailyAvg = timeseries.fixedWindowRollup('1d', { value: avg });\n\nconsole.log('Original TimeSeries events:', timeseries.events().map(e => e.data().toJSON()));\nconsole.log('\\nDaily Average TimeSeries events:', dailyAvg.events().map(e => e.data().toJSON()));\n\n// Example: Get overall average value of a specific column\nconst overallAvg = timeseries.avg('value');\nconsole.log(`\\nOverall average temperature: ${overallAvg}`);\n\n// Example: Create and intersect TimeRanges\nconst tr1 = new TimeRange('2024-01-01T00:00:00Z', '2024-01-02T00:00:00Z');\nconst tr2 = new TimeRange('2024-01-01T12:00:00Z', '2024-01-02T12:00:00Z');\nconst intersection = tr1.intersection(tr2);\nconsole.log(`\\nIntersection of TimeRanges: ${intersection ? intersection.toString() : 'No intersection'}`);","lang":"typescript","description":"Demonstrates creating a TimeSeries, performing a daily average rollup, calculating an overall average, and working with TimeRange intersections.","tag":null,"tag_description":null,"last_tested":null,"results":[]},"compatibility":null}