pond-ts API Reference (core)
    Preparing search index...

    Class Event<K, D>

    An immutable event made of a temporal key and typed payload data.

    const event = new Event(
    new Time(new Date("2025-01-01T00:00:00.000Z")),
    { cpu: 0.42, host: "api-1" },
    );

    event.get("cpu"); // 0.42
    event.timeRange(); // TimeRange for the event extent

    Type Parameters

    Index

    Constructors

    Methods

    • Example: event.asTime({ at: "center" }). Converts the event key to a point-in-time key using the supplied anchor within the current extent.

      Parameters

      • options: { at?: "begin" | "end" | "center" } = {}

      Returns Event<Time, D>

    • Example: event.collapse(["in", "out"], "avg", fn). Collapses selected payload fields into a single derived field using the supplied reducer.

      Type Parameters

      • const Keys extends readonly (keyof D)[]
      • Name extends string
      • R extends ScalarValue

      Parameters

      Returns Event<K, Readonly<Omit<D, Keys[number]> & Record<Name, R>>>

    • Example: event.collapse(["in", "out"], "avg", fn). Collapses selected payload fields into a single derived field using the supplied reducer.

      Type Parameters

      • const Keys extends readonly (keyof D)[]
      • Name extends string
      • R extends ScalarValue

      Parameters

      • keys: Keys
      • output: Name
      • reducer: (values: Pick<D, Keys[number]>) => R
      • options: { append: true }

      Returns Event<K, Readonly<D & Record<Name, R>>>

    • Example: event.merge({ host: "api-1" }). Returns a new event with a shallow payload merge applied.

      Type Parameters

      • U extends object

      Parameters

      • patch: U

      Returns Event<K, Readonly<D & U>>

    • Example: event.rename({ cpu: "usage" }). Returns a new event with payload fields renamed according to the supplied mapping.

      Type Parameters

      • const Mapping extends Partial<{ [K in string]: string }>

      Parameters

      Returns Event<
          K,
          Readonly<
              {
                  [Name in string as Name extends keyof Mapping
                      ? Mapping[Name] extends string ? any[any] : Name
                      : Name]: D[Name]
              },
          >,
      >

    • Example: event.select("cpu", "healthy"). Returns a new event containing only the selected payload fields.

      Type Parameters

      • const Keys extends readonly (keyof D)[]

      Parameters

      Returns Event<K, Readonly<Pick<D, Keys[number]>>>

    • Example: event.toJsonRow(schema). Returns the JSON-shape row for this event — like Event.toRow but with the key serialized to its JSON form (numeric ms / [start, end] / [value, start, end]) and undefined cells emitted as null.

      Pass { rowFormat: 'object' } to get the schema-keyed object shape instead of the array tuple.

      Mirrors TimeSeries.toJSON's row-level serialization, so event.toJsonRow(schema) plugs straight into a wire envelope that the receiver feeds into LiveSeries.pushJson(...) or LiveSeries.fromJSON(...).

      Trust contract: same as Event.toRow — no validation against schema. Mismatched column names produce null cells in the JSON output (serializeJsonValue(undefined)), which round-trip through pushJson as undefined. Pass the same as const schema the event was originally produced under.

      Type Parameters

      Parameters

      • schema: S
      • Optionaloptions: { rowFormat?: "array" }

      Returns JsonRowForSchema<S>

    • Example: event.toJsonRow(schema). Returns the JSON-shape row for this event — like Event.toRow but with the key serialized to its JSON form (numeric ms / [start, end] / [value, start, end]) and undefined cells emitted as null.

      Pass { rowFormat: 'object' } to get the schema-keyed object shape instead of the array tuple.

      Mirrors TimeSeries.toJSON's row-level serialization, so event.toJsonRow(schema) plugs straight into a wire envelope that the receiver feeds into LiveSeries.pushJson(...) or LiveSeries.fromJSON(...).

      Trust contract: same as Event.toRow — no validation against schema. Mismatched column names produce null cells in the JSON output (serializeJsonValue(undefined)), which round-trip through pushJson as undefined. Pass the same as const schema the event was originally produced under.

      Type Parameters

      Parameters

      • schema: S
      • options: { rowFormat: "object" }

      Returns JsonObjectRowForSchema<S>

    • Example: event.toRow(schema). Returns the typed-row tuple for this event in the column order declared by schema[key, ...values].

      Use this in batch-listener fanout to convert a stream of Event objects into the same shape LiveSeries.toRows() / pushMany(rows) consume, without walking columns by hand:

      live.on('batch', (events) => {
      const rows = events.map((e) => e.toRow(schema));
      sendOverWire(rows); // codec of your choice
      });

      Trust contract: no validation against schema. If the caller passes a schema whose value-column names don't match the event's payload keys, data[col.name] is undefined for every mismatched column and the row is silently corrupt — downstream pushMany(rows) accepts it (column count matches), but reads via event.get('col') from the resulting events return undefined. Pass the same as const schema the event was originally produced under.

      Type Parameters

      Parameters

      • schema: S

      Returns RowForSchema<S>