Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
var api = this;
var instanceId;
var stores = {};
var revLimit = opts.revs_limit;
var db;
var name = opts.name;
// TODO: this is undocumented and unused probably
/* istanbul ignore else */
if (typeof opts.createIfMissing === 'undefined') {
opts.createIfMissing = true;
}
var leveldown = opts.db;
var dbStore;
var leveldownName = pouchdbUtils.functionName(leveldown);
if (dbStores.has(leveldownName)) {
dbStore = dbStores.get(leveldownName);
} else {
dbStore = new pouchdbCollections.Map();
dbStores.set(leveldownName, dbStore);
}
if (dbStore.has(name)) {
db = dbStore.get(name);
afterDBCreated();
} else {
dbStore.set(name, sublevel(levelup(name, opts, function (err) {
/* istanbul ignore if */
if (err) {
dbStore.delete(name);
return callback(err);
}
api._destroy = function (opts, callback) {
var dbStore;
var leveldownName = functionName(leveldown);
/* istanbul ignore else */
if (dbStores.has(leveldownName)) {
dbStore = dbStores.get(leveldownName);
} else {
return callDestroy(name, callback);
}
/* istanbul ignore else */
if (dbStore.has(name)) {
levelChanges.removeAllListeners(name);
dbStore.get(name).close(function () {
dbStore.delete(name);
callDestroy(name, callback);
});
} else {
api._destroy = function (opts, callback) {
var dbStore;
var leveldownName = pouchdbUtils.functionName(leveldown);
/* istanbul ignore else */
if (dbStores.has(leveldownName)) {
dbStore = dbStores.get(leveldownName);
} else {
return callDestroy(name, callback);
}
/* istanbul ignore else */
if (dbStore.has(name)) {
levelChanges.removeAllListeners(name);
dbStore.get(name).close(function () {
dbStore.delete(name);
callDestroy(name, callback);
});
} else {
api._destroy = function (opts, callback) {
var dbStore;
var leveldownName = functionName(leveldown);
/* istanbul ignore else */
if (dbStores.has(leveldownName)) {
dbStore = dbStores.get(leveldownName);
} else {
return callDestroy(name, callback);
}
/* istanbul ignore else */
if (dbStore.has(name)) {
levelChanges.removeAllListeners(name);
dbStore.get(name).close(function () {
dbStore.delete(name);
callDestroy(name, callback);
});
} else {
var api = this;
var instanceId;
var stores = {};
var revLimit = opts.revs_limit;
var db;
var name = opts.name;
// TODO: this is undocumented and unused probably
/* istanbul ignore else */
if (typeof opts.createIfMissing === 'undefined') {
opts.createIfMissing = true;
}
var leveldown = opts.db;
var dbStore;
var leveldownName = functionName(leveldown);
if (dbStores.has(leveldownName)) {
dbStore = dbStores.get(leveldownName);
} else {
dbStore = new Map();
dbStores.set(leveldownName, dbStore);
}
if (dbStore.has(name)) {
db = dbStore.get(name);
afterDBCreated();
} else {
dbStore.set(name, sublevel(levelup(leveldown(name), opts, function (err) {
/* istanbul ignore if */
if (err) {
dbStore.delete(name);
return callback(err);
}
api._info = function (callback) {
var res = {
doc_count: db._docCount,
update_seq: db._updateSeq,
backend_adapter: pouchdbUtils.functionName(leveldown)
};
return process.nextTick(function () {
callback(null, res);
});
};
api._info = function (callback) {
var res = {
doc_count: db._docCount,
update_seq: db._updateSeq,
backend_adapter: pouchdbUtils.functionName(leveldown)
};
return process.nextTick(function () {
callback(null, res);
});
};
api._info = function (callback) {
var res = {
doc_count: db._docCount,
update_seq: db._updateSeq,
backend_adapter: functionName(leveldown)
}
return process.nextTick(function () {
callback(null, res)
})
}
api._info = function (callback) {
var res = {
doc_count: db._docCount,
update_seq: db._updateSeq,
backend_adapter: functionName(leveldown)
};
return nextTick(function () {
callback(null, res);
});
};
api._info = function (callback) {
var res = {
doc_count: db._docCount,
update_seq: db._updateSeq,
backend_adapter: functionName(leveldown)
};
return process.nextTick(function () {
callback(null, res);
});
};