Object.defineProperty(exports, "__esModule", { value: true });
const levelup = require("levelup");
const leveldown = require("leveldown");
const cacheLevelDBGet_1 = require("./cacheLevelDBGet");
class LocStore {
    constructor(storePath) {
        this.db = levelup(leveldown(storePath));
        this._cachedGet = cacheLevelDBGet_1.cacheLevelDBGet(this.db);
    }
    write(locs, callback) {
        var ops = [];
        Object.keys(locs).forEach(key => {
            ops.push({
                type: "put",
                key: key,
                value: JSON.stringify(locs[key])
            });
        });
        this.db.batch(ops, function (err) {
            if (err)
                return console.log("Ooops!  - level db error", err);
            callback();
        });
    }
    getLoc(loc, callback) {
        this._cachedGet(loc, (err, value) => {
            if (err) {
                throw err;
            }
            callback(JSON.parse(value.toString()));
        });
    }
}
exports.LocStore = LocStore;
//# sourceMappingURL=LocStore.js.map