redis-time-series-ts
Version:
Javascript RedisTimeSeries client
52 lines (51 loc) • 1.24 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.Label = void 0;
/**
* A `label`-`value` object
*/
class Label {
/**
* Creates a new label
*
* @param name the name of the label
* @param value the value represented by the label
*
* @remarks
* ```
*
* // Example
*
* const sensorLabel = new Label('sensor', 1);
* sensorLabel.getName() // 'sensor'
* sensorLabel.getValue() // 1
* sensorLabel.flatten() // [sensor, 1]
*
* const temp = 24, retention=24*3600,
* chunkSize=8000, dupPolicy='LAST';
* const tempLabel = new Label('temp', temp < 15 ? 'cold': 'warm');
* const labels = [sensorLabel, tempLabel]
* const rts.create(
* 'sensor:temp',
* labels,
* retention,
* chunkSize,
* dupPolicy
* );
* ```
*/
constructor(name, value) {
this.name = name;
this.value = value;
}
getName() {
return this.name;
}
getValue() {
return this.value;
}
flatten() {
return [this.getName(), this.getValue()];
}
}
exports.Label = Label;