redis-time-series-ts
Version:
Javascript RedisTimeSeries client
42 lines • 1.53 kB
TypeScript
import { StringNumberArray } from "../index";
/**
* A `key`-`value`-`timestamp` object
*/
export declare class Sample {
private key;
private value;
private timestamp;
/**
* Creates a Sample object
*
* @param key Key name for timeseries
* @param value The value of the sample
* @param timestamp The timestamp of the sample in ms
* @returns the created Sample object
*
* @remarks
* ```
* // Example
* const tsSample = new Sample('temperature:2:32', 25, 1609682633000);
*
* tsSample.getKey(); // 'temperature:2:32'
* tsSample.setKey('temperature:5:15'); // Sample('temperature:5:15', 25, 1609682633000)
* tsSample.getValue(); // 25
* tsSample.setValue(27); // Sample('temperature:5:15', 27, 1609682633000)
* tsSample.getTimestamp(); // 1609682633000
* tsSample.setTimestamp(1609682634000); // Sample('temperature:5:15', 27, 1609682634000)
* tsSample.flatten(); // ['temperature:5:15', 1609682634000, 27]
* ```
*/
constructor(key: string, value: number, timestamp?: number);
getKey(): string;
setKey(key: string): Sample;
getValue(): number;
setValue(value: number): Sample;
getTimestamp(): string | number;
setTimestamp(timestamp?: number): Sample;
flatten(): StringNumberArray;
protected validateTimestamp(timestamp?: number): string | number;
protected isValidTimestamp(timestamp: number): boolean;
}
//# sourceMappingURL=sample.d.ts.map