Hi there! Are you looking for the official Deno documentation? Try docs.deno.com for all your Deno learning needs.

timestamp

Attaches a timestamp to each item emitted by an observable indicating when it was emitted

The timestamp operator maps the source observable stream to an object of type {value: T, timestamp: R}. The properties are generically typed. The value property contains the value and type of the source observable. The timestamp is generated by the schedulers now function. By default, it uses the asyncScheduler which simply returns Date.now() (milliseconds since 1970/01/01 00:00:00:000) and therefore is of type number.

Example

In this example there is a timestamp attached to the document's click events

import { fromEvent, timestamp } from 'rxjs';

const clickWithTimestamp = fromEvent(document, 'click').pipe(
  timestamp()
);

// Emits data of type { value: PointerEvent, timestamp: number }
clickWithTimestamp.subscribe(data => {
  console.log(data);
});
function timestamp<T>(timestampProvider?: TimestampProvider): OperatorFunction<T, Timestamp<T>>;
§
timestamp<T>(timestampProvider?: TimestampProvider): OperatorFunction<T, Timestamp<T>>
[src]

§Type Parameters

§Parameters

§
timestampProvider?: TimestampProvider optional
[src]

An object with a now() method used to get the current timestamp.

§Return Type

§

A function that returns an Observable that attaches a timestamp to each item emitted by the source Observable indicating when it was emitted.