@fluent-org/logger
Version:
A node fluent protocol compatible logger
59 lines (58 loc) • 1.86 kB
TypeScript
/// <reference types="node" />
/**
* TS/JS representation of the [Fluentd EventTime](https://github.com/fluent/fluentd/wiki/Forward-Protocol-Specification-v1#eventtime-ext-format) type
*/
declare class EventTime {
/**
* The epoch of this EventTime (seconds since midnight, Jan 1st, 1970)
*/
get epoch(): number;
/**
* The nano part of this EventTime (epoch + nano = timestamp nanos)
*/
get nano(): number;
private _epoch;
private _nano;
/**
* Creates a new EventTime object
* @param epoch The epoch (seconds since midnight, Jan 1st, 1970)
* @param nano The nano part (epoch + nano = timestamp)
*/
constructor(epoch: number, nano: number);
/**
* Packs the `EventTime` into a buffer
* @internal
* @param eventTime The `EventTime` object to pack
* @returns The serialized `EventTime`
*/
static pack(eventTime: EventTime): Buffer;
/**
* Unpacks an `EventTime` from a buffer
* @internal
* @param buffer The buffer to read the `EventTime` from
* @returns The deserialized `EventTime`.
*/
static unpack(buffer: Buffer): EventTime;
/**
* Returns the current timestamp as an `EventTime`
*
* Similar to `Date.now()`
* @returns The EventTime representation of the current timestamp
*/
static now(): EventTime;
/**
* Converts a `Date` to an `EventTime`.
*
* @param date The `Date` object to convert
* @returns The equivalent `EventTime`.
*/
static fromDate(date: Date): EventTime;
/**
* Creates a new `EventTime` from a numeric timestamp
*
* @param t The numeric timestamp to convert to an EventTime
* @returns The EventTime representation of the timestamp
*/
static fromTimestamp(t: number): EventTime;
}
export default EventTime;