Home Identifier Source
import {Event} from '@esnet/pond/src/event.js'
public class | source

Event

A generic event

This represents a data object at a single timestamp, supplied at initialization.

The timestamp may be a javascript Date object or a Moment, but is stored internally as ms since UNIX epoch.

The data may be any type.

Asking the Event object for the timestamp returns an integer copy of the number of ms since the UNIX epoch. There's no method on the Event object to mutate the Event timestamp after it is created.

Constructor Summary

Public Constructor
public

constructor(arg1: *, arg2: *)

The creation of an Event is done by combining two parts:

Method Summary

Public Methods
public

data(): Immutable.Map

Access the event data

public

get(key: string): Object

Get specific data out of the Event

public

stringify(): *

public

The timestamp of this data

public

The timestamp of this data, in Local time, as a string.

public

The timestamp of this data, in UTC time, as a string.

public

Returns the Event as a JSON object, essentially:

public

Retruns the Event as a string, useful for serialization.

Public Constructors

public constructor(arg1: *, arg2: *) source

The creation of an Event is done by combining two parts: the timestamp (or time range, or Index...) and the data.

To construct you specify the timestamp as either:

- Javascript Date object
- a Moment, or
- ms timestamp: the number of ms since the UNIX epoch

To specify the data you can supply either:

- a Javascript object containing key values pairs
- an Immutable.Map, or
- a simple type such as an integer. In the case of the simple type
  this is a shorthand for supplying {"value": v}.

Params:

NameTypeAttributeDescription
arg1 *
arg2 *

Public Methods

public data(): Immutable.Map source

Access the event data

Return:

Immutable.Map

Data for the Event

public get(key: string): Object source

Get specific data out of the Event

Params:

NameTypeAttributeDescription
key string

Key to lookup, or "value" if not specified.

Return:

Object

The data associated with this key

public stringify(): * source

Return:

*

public timestamp(): Date source

The timestamp of this data

Return:

Date

Time of this data.

public timestampAsLocalString(): string source

The timestamp of this data, in Local time, as a string.

Return:

string

Time of this data.

public timestampAsUTCString(): string source

The timestamp of this data, in UTC time, as a string.

Return:

string

Time of this data.

public toJSON(): Object source

Returns the Event as a JSON object, essentially: {time: t, data: {key: value, ...}}

Return:

Object

The event as JSON.

public toString(): string source

Retruns the Event as a string, useful for serialization.

Return:

string

The Event as a string