"use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
    return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.LevelDB = void 0;
const levelup_1 = __importDefault(require("levelup"));
const leveldown_1 = __importDefault(require("leveldown"));
class LevelDB {
    constructor(path) {
        this.db = (0, levelup_1.default)((0, leveldown_1.default)(path));
    }
    put(key, value) {
        return new Promise((resolve, reject) => {
            this.db.put(key, value, function (error) {
                if (error)
                    reject(error);
                else
                    resolve(void 0);
            });
        });
    }
    get(key) {
        return new Promise((resolve, reject) => {
            this.db.get(key, function (error, value) {
                if (error && error.type === "NotFoundError")
                    resolve(null);
                else if (error)
                    reject(error);
                else
                    resolve(value);
            });
        });
    }
}
exports.LevelDB = LevelDB;
