Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
function encoder (db: LevelUp$AbstractStorage) {
return encodingDown(db, options);
}
constructor (deps: Injector) {
this.config = deps(Config)
let backend
if (this.config.memdownPersist || this.config.devMode) {
backend = memdown()
} else {
backend = leveldown(resolvePath(this.config.codiusRoot, 'codius.db'))
}
this.db = levelup(encode(backend, { valueEncoding: 'json' }))
}
public constructor(file: string) {
logger('opening file', { file });
this._db = levelup(EncodingDown(RocksDB(file), { valueEncoding: 'json' }));
}
constructor(filename) {
this.db = levelup(encode(leveldown(filename), {
valueEncoding: 'json'
}));
}
async setup(model?: FederatedModel) {
this.db = await LevelUp(
EncodingDown(LevelDown(this.dataDir), {valueEncoding: 'json'}));
try {
this.modelId = await this.db.get('currentModelId');
} catch {
const dict = await model.setup();
await this.writeNewVars(dict.vars as tf.Tensor[]);
}
}