Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: ES6 update of sublevel-pouchdb #8960

Draft
wants to merge 12 commits into
base: master
Choose a base branch
from
Prev Previous commit
Next Next commit
chore: simplify nut.js
  • Loading branch information
Steven-John Lange committed Jun 13, 2024
commit c96a17fcdfc858b9b78e62b390126ebd095357e9
12 changes: 2 additions & 10 deletions packages/node_modules/sublevel-pouchdb/src/nut.js
Original file line number Diff line number Diff line change
@@ -1,20 +1,12 @@
import ltgt from 'ltgt';

function isFunction(f) {
return 'function' === typeof f;
}

function getPrefix(db) {
if (isFunction(db.prefix)) {
if (typeof db.prefix === 'function') {
return db.prefix();
}
return db;
}

function clone(_obj) {
return Object.assign({}, _obj);
}

function nut(db, precodec, codec) {
function encodePrefix(prefix, key, opts1, opts2) {
return precodec.encode([ prefix, codec.encodeKey(key, opts1, opts2 ) ]);
Expand Down Expand Up @@ -77,7 +69,7 @@ function nut(db, precodec, codec) {
return db.close(cb);
},
iterator(_opts) {
const opts = clone(_opts || {});
const opts = Object.assign({}, _opts || {});
const prefix = _opts.prefix || [];

function encodeKey(key) {
Expand Down