text: "use strict";
  var __importDefault = (this && this.__importDefault) || function (mod) {
      return (mod && mod.__esModule) ? mod : { "default": mod };
  };
  Object.defineProperty(exports, "__esModule", { value: true });
  var leveldb_1 = require("./leveldb");
  var level_ws_1 = __importDefault(require("level-ws"));
  var Metric = /** @class */ (function () {
      function Metric(ts, v) {
          this.timestamp = ts;
          this.value = v;
      }
      return Metric;
  }());
  exports.Metric = Metric;
  var MetricsHandler = /** @class */ (function () {
      function MetricsHandler(dbPath) {
          this.db = leveldb_1.LevelDb.open(dbPath);
      }
      MetricsHandler.prototype.save = function (key, metrics, callback) {
          var stream = level_ws_1.default(this.db);
          stream.on('error', callback);
          stream.on('close', callback);
          metrics.forEach(function (m) {
              stream.write({ key: "metrics:" + key + m.timestamp, value: m.value });
          });
          stream.end();
      };
      MetricsHandler.get = function (callback) {
          var result = [
              new Metric('2013-11-04 14:00 UTC', 12),
              new Metric('2013-11-04 14:10 UTC', 13)
          ];
          callback(null, result);
      };
      MetricsHandler.prototype.remove = function (key, callback) {
          this.db.del(key, function (err) {
              if (err)
                  throw err;
          });
          callback(null);
      };
      return MetricsHandler;
  }());
  exports.MetricsHandler = MetricsHandler;
  