Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
import LevelDOWN, { Bytes } from 'leveldown';
// Can use new, or not.
const a = new LevelDOWN("/tmp/db");
const b = LevelDOWN("/tmp/db");
const db = new LevelDOWN("/tmp/db");
db.open(() => {
db.put("key", "value", (err: Error | undefined) => { });
db.put(Buffer.from([1]), "value", { something: true }, (err: Error | undefined) => { });
db.get("key", (err: Error | undefined) => { });
db.get(Buffer.from([1]), { something: true }, (err: Error | undefined, value: Bytes) => { });
db.close((err: Error | undefined) => { });
});
db.clear((err: Error | undefined) => { });
const filePath = path.resolve(home, "pico-engine.log");
const log = configuration.log
? configuration.log
: new KrlLogger(getRotatingFileStream(filePath), "");
const rsRegistry = new RulesetRegistry(home);
const rsEnvironment = new RulesetEnvironment(log);
if (configuration.modules) {
_.each(configuration.modules, function(mod, domain) {
rsEnvironment.modules[domain] = mod;
});
}
const pf = new PicoFramework({
leveldown: leveldown(path.resolve(home, "db")) as any,
environment: rsEnvironment,
rulesetLoader(rid, version) {
return rsRegistry.load(rid, version);
},
onStartupRulesetInitError(pico, rid, version, config, error) {
// TODO mark it as not installed and raise an error event
// throw error;
console.error("TODO raise error", pico.id, rid, version, config, error);
},
onFrameworkEvent(ev) {
switch (ev.type) {
case "startup":
public constructor(dbPath: string) {
// Make sure that the DB directory exists.
const directory = path.dirname(dbPath);
mkdirp.sync(directory);
// Open/create the blocks LevelDB database.
this.db = levelup.default(leveldown(dbPath));
}
function(next) {
// Flush any existing mempool index
if (fs.existsSync(self.mempoolIndexPath)) {
leveldown.destroy(self.mempoolIndexPath, next);
} else {
setImmediate(next);
}
},
function(next) {
server.doorknob.db.close(function() {
leveldown.destroy(path.join(__dirname, 'test.db'), cb)
})
}
function deleteStore (store, cb) {
if (leveldown) {
return leveldown.destroy(store.store.location, cb)
}
cb(null)
}
function deleteStore (store, cb) {
if (leveldown) {
return leveldown.destroy(store.store.location, cb)
}
cb(null)
}
const db = new LevelDOWN("/tmp/db");
db.open(() => {
db.put("key", "value", (err: Error | undefined) => { });
db.put(Buffer.from([1]), "value", { something: true }, (err: Error | undefined) => { });
db.get("key", (err: Error | undefined) => { });
db.get(Buffer.from([1]), { something: true }, (err: Error | undefined, value: Bytes) => { });
db.close((err: Error | undefined) => { });
});
db.clear((err: Error | undefined) => { });
LevelDOWN.destroy("/tmp/db", (err: Error | undefined) => { });
LevelDOWN.repair("/tmp/db", (err: Error | undefined) => { });
async.eachSeries(sBucketList, (sBucketName, next) => {
require('leveldown').repair(
path.join(kfs.utils.coerceTablePath(program.db), sBucketName),
(err) => {
if (err) {
process.stderr.write('[error] ' + err.message);
process.exit(1)
}
process.stdout.write(sBucketName + ' (done!)\n');
next();
}
);
});
}
constructor(filename) {
this.db = levelup(encode(leveldown(filename), {
valueEncoding: 'json'
}));
}