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.begin(). Returns the inclusive event start in milliseconds since epoch.

      Returns number

    • 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.end(). Returns the inclusive event end in milliseconds since epoch.

      Returns number

    • Example: event.get("value"). Returns a single payload field by name.

      Type Parameters

      • Field extends string | number | symbol

      Parameters

      Returns Readonly<D>[Field]

    • 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]>>>